13#ifndef RTCTK_COMPONENTFRAMEWORK_DATAPOINTPATH_HPP
14#define RTCTK_COMPONENTFRAMEWORK_DATAPOINTPATH_HPP
26#include <fmt/format.h>
27#include <mal/utility/Uri.hpp>
119 const std::string&
ToString() const noexcept;
143 operator std::
string() const noexcept;
193 friend std::ostream& operator<<(std::ostream& out, const
DataPointPath& rhs);
196 friend
bool operator==(const
DataPointPath& lhs, const
char* rhs) noexcept;
197 friend
bool operator!=(const
DataPointPath& lhs, const
char* rhs) noexcept {
198 return !(lhs == rhs);
207 return !(lhs == rhs);
216 return !(lhs == rhs);
228 return !(rhs == lhs);
247 return !(rhs == lhs);
287 std::pair<DataPointPath, DataPointPath>
Split()
const;
312 std::vector<DataPointPath>
SplitAll()
const;
335 static bool ValidPath(
const std::string& path);
340 const static char VALID_CHARACTERS[];
343 const static std::regex REGEX_VALID_CHARS;
346DataPointPath
operator"" _dppath(
const char* str, std::size_t len);
351 return lhs.m_path == rhs;
355 return lhs.m_path < rhs;
359 return lhs.m_path <= rhs;
363 return lhs.m_path > rhs;
367 return lhs.m_path >= rhs;
371 return lhs.m_path == rhs;
375 return lhs.m_path < rhs;
379 return lhs.m_path <= rhs;
383 return lhs.m_path > rhs;
387 return lhs.m_path >= rhs;
391 return lhs.m_path == rhs.m_path;
395 return lhs.m_path < rhs.m_path;
399 return lhs.m_path <= rhs.m_path;
403 return lhs.m_path > rhs.m_path;
407 return lhs.m_path >= rhs.m_path;
412 if (not DataPointPath::ValidPath(lhs)) {
428 this->m_path += rhs.m_path;
429 if (not DataPointPath::ValidPath(*
this)) {
436 std::string::value_type this_path_back = this->m_path.empty() ?
'0' : this->m_path.back();
437 std::string::value_type rhs_path_front = rhs.m_path.empty() ?
'0' : rhs.m_path.front();
438 if (this_path_back !=
'/' and rhs_path_front !=
'/') {
440 this->m_path +=
"/" + rhs.m_path;
441 }
else if (this_path_back ==
'/' and rhs_path_front ==
'/') {
443 this->m_path.append(rhs.m_path, 1);
445 this->m_path += rhs.m_path;
454inline DataPointPath::operator std::string() const noexcept {
469struct fmt::formatter<
rtctk::componentFramework::DataPointPath> : fmt::formatter<std::string> {
471 -> fmt::format_context::iterator;
479 std::vector<std::string> string_vec;
480 string_vec.reserve(v.size());
481 for (
auto& path : v) {
482 string_vec.emplace_back(path.ToString());
489 auto string_vec = j.get<std::vector<std::string>>();
490 v.reserve(string_vec.size());
491 for (
auto& str : string_vec) {
Exception class used when an invalid character is used in a DataPointPath.
Definition: dataPointPath.hpp:79
This class provides a wrapper for a data point path.
Definition: dataPointPath.hpp:73
friend bool operator<(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:354
friend bool operator!=(const DataPointPath &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:215
friend bool operator<=(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:252
DataPointPath LastComponent() const
Returns the last component of the path.
Definition: dataPointPath.cpp:101
friend bool operator>=(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:366
elt::mal::Uri ToRepositoryURI(const elt::mal::Uri &base_uri) const
Creates and returns a complete URI.
Definition: dataPointPath.cpp:68
friend bool operator>=(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:239
friend bool operator>(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:236
std::pair< DataPointPath, DataPointPath > Split() const
Splits the path into a base path and last component pair.
Definition: dataPointPath.cpp:72
friend bool operator<(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:230
friend bool operator!=(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:246
friend bool operator>=(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:258
friend bool operator!=(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:227
virtual ~DataPointPath()=default
friend bool operator!=(const DataPointPath &lhs, const std::string &rhs) noexcept
Definition: dataPointPath.hpp:206
friend bool operator<=(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:233
DataPointPath BasePath() const
Returns the base component of the path.
Definition: dataPointPath.cpp:89
friend bool operator<(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:249
DataPointPath & operator/=(const DataPointPath &rhs)
Append another DataPointPath to this DataPointPath with a path seperator (/) in between if needed.
Definition: dataPointPath.hpp:435
const std::string & ToString() const noexcept
Get string representing the DataPointPath.
Definition: dataPointPath.hpp:423
friend std::istream & operator>>(std::istream &input, DataPointPath &path)
Read into DataPointPath from istream.
Definition: dataPointPath.cpp:170
friend bool operator>(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:255
operator std::string() const noexcept
Cast operator to string (implicit).
Definition: dataPointPath.hpp:454
DataPointPath(const char *const new_path)
Create DataPointPath from a null terminated character string.
Definition: dataPointPath.hpp:113
DataPointPath & operator=(DataPointPath &&)=default
DataPointPath & operator=(const DataPointPath &)=default
DataPointPath(DataPointPath &&)=default
friend bool operator==(const std::string &lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:243
friend bool operator==(const char *lhs, const DataPointPath &rhs) noexcept
Definition: dataPointPath.hpp:224
friend bool operator<=(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:358
DataPointPath(const DataPointPath &)=default
std::vector< DataPointPath > SplitAll() const
Splits the path into a list of individual components.
Definition: dataPointPath.cpp:115
friend bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:350
friend bool operator>(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:362
static elt::mal::Uri AppendSuffixToUriPath(const std::string &suffix, const elt::mal::Uri &uri)
Appends a suffix string to the path of a URI.
Definition: dataPointPath.cpp:148
DataPointPath & operator+=(const DataPointPath &rhs)
Append another DataPointPath to this DataPointPath without adding a path seperator,...
Definition: dataPointPath.hpp:427
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:237
Provides macros and utilities for exception handling.
Defines the JSON payload type JsonPayload.
Definition: commandReplier.cpp:22
DataPointPath operator/(DataPointPath lhs, const DataPointPath &rhs)
Definition: dataPointPath.hpp:418
void to_json(JsonPayload &j, const std::vector< DataPointPath > &v)
Definition: dataPointPath.hpp:478
bool operator<(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:354
void from_json(const JsonPayload &j, std::vector< DataPointPath > &v)
Definition: dataPointPath.hpp:488
std::ostream & operator<<(std::ostream &os, AlertServiceIf::AlertStatus const &status)
Definition: alertServiceIf.cpp:60
bool operator>=(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:366
nlohmann::json JsonPayload
Type requirements:
Definition: jsonPayload.hpp:25
bool operator<=(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:358
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:350
DataPointPath operator+(DataPointPath lhs, const DataPointPath &rhs)
Definition: dataPointPath.hpp:410
bool operator>(const DataPointPath &lhs, const char *rhs) noexcept
Definition: dataPointPath.hpp:362
Definition: commandReplier.cpp:22
DataPointPath m_path
Definition: populateConfig.cpp:165