RTC Toolkit  0.1.0-alpha
dataPointPath.hpp
Go to the documentation of this file.
1 
9 #ifndef RTCTK_COMPONENTFRAMEWORK_DATAPOINTPATH_HPP
10 #define RTCTK_COMPONENTFRAMEWORK_DATAPOINTPATH_HPP
11 
12 #include <stdexcept>
13 #include <iostream>
14 #include <string>
15 #include <regex>
16 #include <algorithm>
17 #include <string_view>
18 #include <type_traits>
19 #include <regex>
20 #include <mal/utility/Uri.hpp>
21 #include "exceptions.hpp"
22 
23 namespace rtctk::componentFramework {
24 
30 class DataPointPath {
31  public:
36  public:
37  using ::elt::error::CiiBaseException::CiiBaseException;
38  explicit InvalidPathException(const std::string& path);
39 
40  };
41 
42  DataPointPath() = default;
43  DataPointPath(const DataPointPath&) = default;
47  virtual ~DataPointPath() = default;
48 
54  explicit DataPointPath(const std::string& new_path);
55 
61  explicit DataPointPath(std::string&& new_path);
62 
63 
69  explicit DataPointPath(const char *const new_path) : DataPointPath(std::string(new_path)) {}
70 
74  const std::string& ToString() const noexcept;
75 
81  DataPointPath& operator=(const std::string& new_path);
82 
88  DataPointPath& operator=(std::string&& new_path);
89 
95  operator std::string() const noexcept;
96 
97  // Append Operators
103  DataPointPath& operator+=(const DataPointPath& rhs);
108  DataPointPath& operator/=(const DataPointPath& rhs);
109 
115  friend DataPointPath operator+(DataPointPath lhs, const DataPointPath& rhs);
116 
122  friend DataPointPath operator/(DataPointPath lhs, const DataPointPath& rhs);
123 
127  friend std::ostream& operator<<(std::ostream& out, const DataPointPath& rhs);
128 
129  //Comparison operators for DataPointPath, char * and string
130  friend bool operator==(const DataPointPath& lhs, const char * rhs) noexcept;
131  friend bool operator!=(const DataPointPath& lhs, const char * rhs) noexcept {return !(lhs==rhs);}
132 
133  friend bool operator==(const DataPointPath& lhs, const std::string& rhs) noexcept;
134  friend bool operator!=(const DataPointPath& lhs, const std::string& rhs) noexcept {return !(lhs==rhs);}
135 
136  friend bool operator==(const DataPointPath& lhs, const DataPointPath& rhs) noexcept;
137  friend bool operator!=(const DataPointPath& lhs, const DataPointPath& rhs) noexcept {return !(lhs==rhs);}
138 
139  //symmetry
140  friend bool operator==(const char * lhs, const DataPointPath& rhs) noexcept {return rhs==lhs;}
141  friend bool operator!=(const char * lhs, const DataPointPath& rhs) noexcept {return !(rhs==lhs);}
142 
143  friend bool operator==(const std::string& lhs, const DataPointPath& rhs) noexcept {return rhs==lhs;}
144  friend bool operator!=(const std::string& lhs, const DataPointPath& rhs) noexcept {return !(rhs==lhs);}
145 
149  friend std::istream &operator>>( std::istream &input, DataPointPath& path );
155  ::elt::mal::Uri ToRepositoryURI(const ::elt::mal::Uri base_uri) const;
156 
157  private:
158  const static std::regex regex_valid_chars;
159 
160  static bool ValidPath(const std::string& path);
161 
162  std::string path;
163 
167  const static char VALID_CHARACTERS[];
168 }; // class RepositoryPath
169 
170 DataPointPath operator"" _dppath (const char* str, std::size_t len);
171 
172 // inline implementations
173 
174 inline bool operator==(const DataPointPath& lhs, const char * rhs) noexcept {
175  return lhs.path == rhs;
176 }
177 
178 inline bool operator==(const DataPointPath& lhs, const std::string& rhs) noexcept {
179  return lhs.path == rhs;
180 }
181 
182 inline bool operator==(const DataPointPath& lhs, const DataPointPath& rhs) noexcept {
183  return lhs.path == rhs.path;
184 }
185 
187  lhs += rhs;
188  return lhs;
189 }
190 
192  lhs /= rhs;
193  return lhs;
194 }
195 
196 inline const std::string& DataPointPath::ToString() const noexcept {
197  return this->path;
198 }
199 
201  this->path += rhs.path;
202  return *this;
203 }
204 
206  this->path += "/"+rhs.path;
207  return *this;
208 }
209 
210 inline DataPointPath operator"" _dppath (const char* str, std::size_t len) {
211  return DataPointPath(std::string(str));
212 }
213 
214 inline DataPointPath::operator std::string() const noexcept{
215  return path;
216 }
217 
218 inline std::ostream& operator<<(std::ostream& out, const DataPointPath& rhs) {
219  out << rhs.path;
220  return out;
221 }
222 
223 } // namespace rtctk::componentFramework
224 
225 #endif // RTCTK_COMPONENTFRAMEWORK_DATAPOINTPATH_HPP
exceptions.hpp
Provides macros and utilities for exception handling.
rtctk::componentFramework::DataPointPath::DataPointPath
DataPointPath(DataPointPath &&)=default
rtctk::componentFramework::operator/
DataPointPath operator/(DataPointPath lhs, const DataPointPath &rhs)
Definition: dataPointPath.hpp:191
rtctk::componentFramework::DataPointPath::operator>>
friend std::istream & operator>>(std::istream &input, DataPointPath &path)
Definition: dataPointPath.cpp:64
elt::error::CiiBaseException
Base class for the exceptions.
Definition: exceptions.hpp:345
rtctk::componentFramework::DataPointPath::operator=
DataPointPath & operator=(DataPointPath &&)=default
rtctk::componentFramework
Definition: rtcComponent.hpp:17
rtctk::componentFramework::DataPointPath::ToRepositoryURI
::elt::mal::Uri ToRepositoryURI(const ::elt::mal::Uri base_uri) const
Return URI.
Definition: dataPointPath.cpp:56
rtctk::componentFramework::DataPointPath::operator==
friend bool operator==(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:140
rtctkExampleDataTaskRobotTest.path
string path
Definition: rtctkExampleDataTaskRobotTest.py:228
rtctk::componentFramework::DataPointPath::ToString
const std::string & ToString() const noexcept
Definition: dataPointPath.hpp:196
rtctk::componentFramework::DataPointPath::~DataPointPath
virtual ~DataPointPath()=default
rtctk::componentFramework::DataPointPath::DataPointPath
DataPointPath()=default
rtctk::componentFramework::DataPointPath::operator=
DataPointPath & operator=(const DataPointPath &)=default
rtctk::componentFramework::DataPointPath::operator!=
friend bool operator!=(const DataPointPath &lhs, const std::string &rhs) noexcept
Definition: dataPointPath.hpp:134
rtctk::componentFramework::DataPointPath::DataPointPath
DataPointPath(const DataPointPath &)=default
rtctk::componentFramework::DataPointPath::operator==
friend bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:174
rtctk::componentFramework::DataPointPath::operator==
friend bool operator==(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:143
rtctk::componentFramework::DataPointPath::InvalidPathException::InvalidPathException
InvalidPathException(const std::string &path)
Definition: dataPointPath.cpp:14
rtctk::componentFramework::DataPointPath::operator+=
DataPointPath & operator+=(const DataPointPath &rhs)
Append another DataPointPath to this DataPointPath without adding a path seperator.
Definition: dataPointPath.hpp:200
rtctk::componentFramework::DataPointPath::operator!=
friend bool operator!=(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:141
rtctk::componentFramework::DataPointPath::InvalidPathException
Definition: dataPointPath.hpp:35
rtctk::componentFramework::operator<<
std::ostream & operator<<(std::ostream &out, const DataPointPath &rhs)
Definition: dataPointPath.hpp:218
std
Definition: mudpiProcessingError.hpp:109
rtctk::componentFramework::DataPointPath::operator!=
friend bool operator!=(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:144
rtctk::componentFramework::DataPointPath::DataPointPath
DataPointPath(const char *const new_path)
Create DataPointPath from a const char *.
Definition: dataPointPath.hpp:69
rtctk::componentFramework::DataPointPath::operator!=
friend bool operator!=(const DataPointPath &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:137
rtctk::componentFramework::DataPointPath
Definition: dataPointPath.hpp:30
rtctk::componentFramework::DataPointPath::operator/=
DataPointPath & operator/=(const DataPointPath &rhs)
Append another DataPointPath to this DataPointPath with a path seperator inbetween.
Definition: dataPointPath.hpp:205
rtctk::componentFramework::operator==
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:174
rtctk::componentFramework::operator+
DataPointPath operator+(DataPointPath lhs, const DataPointPath &rhs)
Definition: dataPointPath.hpp:186