QMCPACK
hdf_path.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Steven Hahn, hahnse@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Steven Hahn, hahnse@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_HDF5_PATH_H
14 #define QMCPLUSPLUS_HDF5_PATH_H
15 
16 #include <initializer_list>
17 #include <string>
18 #include <string_view>
19 
20 namespace qmcplusplus
21 {
22 class hdf_path
23 {
24 public:
25  /** Constructs an empty path.
26  */
27  hdf_path();
28  /** Constructs a path whose pathname is the same as that of p
29  * @param p pathname
30  */
31  hdf_path(std::string_view p);
32  /** Appends elements to the path with a directory separator
33  * @param p pathname
34  */
35  hdf_path& append(std::string_view p);
36  hdf_path& append(const hdf_path& p);
37  /** Concatenates two paths without introducing a directory separator
38  * @param p pathname
39  * @return *this
40  */
41  hdf_path& concat(std::string_view p);
42  hdf_path& concat(const hdf_path& p);
43  /** Appends elements to the path with a directory separator
44  * @param p pathname
45  * @return *this
46  */
47  hdf_path& operator/=(std::string_view p);
48  hdf_path& operator/=(const hdf_path& p);
49  /** Concatenates two paths without introducing a directory separator
50  * @param p pathname
51  * @return *this
52  */
53  hdf_path& operator+=(std::string_view p);
54  hdf_path& operator+=(const hdf_path& p);
55  /** Remove last subgroup in path
56  * @return *this
57  */
59  /** Replace the last subgroup in path
60  * @param p subgroup to replace last in path
61  * @return *this
62  */
63  hdf_path& replace_subgroup(std::string_view p);
64  /** Return std::string for use with HDF5
65  * @return path as a std::string
66  */
67  const std::string& string() const { return path_; }
68  /** Does the path absolute (true) or relative to the current group in hdf_archive (false)?
69  * @return does the path begin with '/'
70  */
71  bool has_root_directory() const;
72 
73 private:
74  std::string path_;
75 };
76 
77 /** concatenates two paths with a directory separator
78  * @param lhs left-hand side of directory separator
79  * @param rhs right-hand side of directory separator
80  * @return path
81  */
82 hdf_path operator/(const hdf_path& lhs, const hdf_path& rhs);
83 hdf_path operator/(const hdf_path& lhs, const std::string& rhs);
84 hdf_path operator/(const hdf_path& lhs, const char* rhs);
85 /** Checks whether lhs and rhs are equal.
86  * @param lhs first path
87  * @param rhs second path
88  * @return result
89  */
90 bool operator==(const hdf_path& lhs, const hdf_path& rhs) noexcept;
91 
92 } // namespace qmcplusplus
93 #endif // QMCPLUSPLUS_HDF5_PATH_H
const std::string & string() const
Return std::string for use with HDF5.
Definition: hdf_path.h:67
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
bool operator==(const Matrix< T, Alloc > &lhs, const Matrix< T, Alloc > &rhs)
Definition: OhmmsMatrix.h:388
hdf_path & replace_subgroup(std::string_view p)
Replace the last subgroup in path.
Definition: hdf_path.cpp:67
std::string path_
Definition: hdf_path.h:74
hdf_path & concat(std::string_view p)
Concatenates two paths without introducing a directory separator.
Definition: hdf_path.cpp:31
hdf_path & append(std::string_view p)
Appends elements to the path with a directory separator.
Definition: hdf_path.cpp:20
hdf_path & remove_subgroup()
Remove last subgroup in path.
Definition: hdf_path.cpp:47
hdf_path & operator+=(std::string_view p)
Concatenates two paths without introducing a directory separator.
Definition: hdf_path.cpp:43
bool has_root_directory() const
Does the path absolute (true) or relative to the current group in hdf_archive (false)?
Definition: hdf_path.cpp:73
MakeReturn< BinaryNode< OpDivide, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t operator/(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
hdf_path & operator/=(std::string_view p)
Appends elements to the path with a directory separator.
Definition: hdf_path.cpp:39
hdf_path()
Constructs an empty path.