Bayeux  3.4.1
Core Foundation library for SuperNEMO
utils.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2015 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of datatools.
7 //
8 // datatools is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // datatools is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with datatools. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef DATATOOLS_UI_UTILS_H
22 #define DATATOOLS_UI_UTILS_H
23 
24 // Standard libraries:
25 #include <string>
26 #include <list>
27 
28 namespace datatools {
29 
30  namespace ui {
31 
32  namespace path {
33 
34  // Return the root path ("/")
35  const std::string & root_path();
36 
37  // Return the home path ("~")
38  const std::string & home_interface_path();
39 
40  // Return the current interface path (".")
41  const std::string & current_interface_path();
42 
43  // Return the current parent interface path ("..")
44  const std::string & current_parent_interface_path();
45 
46  // Return the path separator ('/')
47  char sep();
48 
49  // Return the executable suffix ('*')
50  char exec();
51 
61  std::string remove_trailing_sep(const std::string & path_);
62 
64  std::string basename(const std::string & path);
65 
67  std::string parent_path(const std::string & path);
68 
70  bool is_hidden(const std::string & name_);
71 
73  bool is_valid_name(const std::string & name_);
74 
76  bool is_valid_path(const std::string & path_);
77 
79  bool is_absolute_path(const std::string & path_);
80 
82  bool build_leaf_full_path(const std::string & parent_path_,
83  const std::string & leaf_name_,
84  std::string & full_leaf_path_);
85 
87  bool is_child_of(const std::string & child_candidate_, const std::string & parent_path_);
88 
90  std::string build_path(const std::list<std::string> & segments_);
91 
92  } // namespace path
93 
94  } // namespace ui
95 
96 } // namespace datatools
97 
98 #endif // DATATOOLS_UI_UTILS_H
99 
100 // Local Variables: --
101 // mode: c++ --
102 // c-file-style: "gnu" --
103 // tab-width: 2 --
104 // End: --
std::string build_path(const std::list< std::string > &segments_)
Return the parent interface path of a command or interface path.
bool is_child_of(const std::string &child_candidate_, const std::string &parent_path_)
Check if an absolute path if a child of another absolute path.
const std::string & current_parent_interface_path()
bool is_hidden(const std::string &name_)
Check if a name is hidden.
bool is_valid_name(const std::string &name_)
Check if a name is valid.
const std::string & root_path()
bool is_valid_path(const std::string &path_)
Check if a path is valid.
const std::string & home_interface_path()
std::string remove_trailing_sep(const std::string &path_)
bool is_absolute_path(const std::string &path_)
Check if a path is absolute.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
std::string basename(const std::string &path)
Return the basename of a command or interface path.
const std::string & current_interface_path()
bool build_leaf_full_path(const std::string &parent_path_, const std::string &leaf_name_, std::string &full_leaf_path_)
Build the full path of a leaf with respect to its parent path.
std::string parent_path(const std::string &path)
Return the parent interface path of a command or interface path.