h5cpp  0.3.3
A modern C++ wrapper for the HDF5 C library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
path.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5cpp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Authors:
23 // Eugen Wintersberger <eugen.wintersberger@desy.de>
24 // Martin Shetty <martin.shetty@esss.se>
25 // Created on: Aug 24, 2017
26 //
27 #pragma once
28 
29 #include <list>
30 #include <string>
31 #include <h5cpp/core/windows.hpp>
32 
33 namespace hdf5 {
34 
50 {
51  public:
52  using value_type = std::string;
53  using iterator = std::list<value_type>::iterator;
54  using const_iterator = std::list<value_type>::const_iterator;
55  using reverse_iterator = std::list<value_type>::reverse_iterator;
56  using const_reverse_iterator= std::list<value_type>::const_reverse_iterator;
57 
64  Path();
65 
72  Path(const std::string &str);
73  Path(const char *str);
74 
81  Path(const_iterator first_element, const_iterator last_element);
82 
86  Path(const Path &p) = default;
87 
88  explicit operator std::string() const
89  {
90  return to_string();
91  }
92 
99  size_t size() const noexcept;
100 
102  const_iterator begin() const;
116  const_iterator end() const;
118 
119 
121  const_reverse_iterator rbegin() const;
136  const_reverse_iterator rend() const;
138 
155  bool absolute() const noexcept;
156 
173  void absolute(bool value) noexcept;
174 
194  bool is_root() const;
195 
204  bool is_name() const;
205 
218  std::string name() const;
219 
238  Path parent() const;
239 
253  void append(const Path& p);
254 
255  Path relative_to(const Path& base) const;
256 
257  Path& operator+=(const Path &other);
258 
263  DLL_EXPORT friend bool operator==(const Path &lhs, const Path &rhs);
264  DLL_EXPORT friend Path common_base(const Path& lhs, const Path& rhs);
265 
266  private:
267  bool absolute_;
268 #ifdef _MSC_VER
269 #pragma warning(push)
270 #pragma warning(disable:4251)
271 #endif
272  std::list<std::string> link_names_;
273 #ifdef _MSC_VER
274 #pragma warning(pop)
275 #endif
276 
277  void from_string(const std::string &str);
278  std::string to_string() const;
279 
280  void sanitize();
281 };
282 
283 
284 DLL_EXPORT bool operator!=(const Path &lhs, const Path &rhs);
285 
286 DLL_EXPORT Path operator+(const Path &lhs,const Path &rhs);
287 
288 
289 DLL_EXPORT std::ostream &operator<<(std::ostream &stream,const Path &path);
290 
291 } // namespace hdf5
std::list< value_type >::const_iterator const_iterator
Definition: path.hpp:54
std::list< value_type >::reverse_iterator reverse_iterator
Definition: path.hpp:55
std::list< value_type >::iterator iterator
Definition: path.hpp:53
DLL_EXPORT Iterator operator+(const Iterator &a, ssize_t b)
DLL_EXPORT std::ostream & operator<<(std::ostream &stream, const IterationIndex &index)
DLL_EXPORT bool operator!=(const ObjectHandle &lhs, const ObjectHandle &rhs)
not equal to operator
Definition: attribute.hpp:43
std::string value_type
Definition: path.hpp:52
path to a node object
Definition: path.hpp:49
#define DLL_EXPORT
Definition: windows.hpp:35
DLL_EXPORT bool operator==(const ObjectHandle &lhs, const ObjectHandle &rhs)
equality operator
std::list< value_type >::const_reverse_iterator const_reverse_iterator
Definition: path.hpp:56