Mantid
Loading...
Searching...
No Matches
NexusAddress.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidNexus/DllConfig.h"
10
11#include <filesystem>
12#include <memory>
13#include <vector>
14
15namespace Mantid::Nexus {
16
22class MANTID_NEXUS_DLL NexusAddress {
23
24public:
25 NexusAddress(std::filesystem::path const &p);
26
27 NexusAddress(std::string const &p);
28
29 NexusAddress(char const *const p);
30
32
33 NexusAddress &operator=(NexusAddress const &nd) = default;
34
35 NexusAddress &operator=(std::string const &s);
36
37 NexusAddress(NexusAddress const &nd) = default;
38
39 ~NexusAddress() = default;
40
41 // comparison operators
42
43 bool operator==(NexusAddress const &p) const;
44
45 bool operator==(std::string const &s) const;
46
47 bool operator==(char const *const s) const;
48
49 bool operator!=(NexusAddress const &p) const;
50
51 bool operator!=(std::string const &s) const;
52
53 bool operator!=(char const *const s) const;
54
55 // concatenation
56
57 NexusAddress operator/(std::string const &s) const;
58
59 NexusAddress operator/(char const *const s) const;
60
61 NexusAddress operator/(NexusAddress const &p) const;
62
63 NexusAddress &operator/=(std::string const &s);
64
65 NexusAddress &operator/=(char const *const s);
66
68
69 // access
70
71 bool isAbsolute() const;
72
73 bool isRoot() const;
74
75 NexusAddress parent_path() const;
76
77 NexusAddress fromRoot() const;
78
79 NexusAddress stem() const;
80
81 static NexusAddress root();
82
83 std::vector<std::string> parts() const;
84
85 // printing
86
87 std::string operator+(std::string const &s) const;
88
89 std::string operator+(char const s[]) const;
90
91 operator std::string() const { return m_resolved_path; }
92
93 std::string const &string() const { return m_resolved_path; }
94
95 char const *c_str() const { return m_resolved_path.c_str(); }
96
97private:
99 std::filesystem::path m_path;
100 // in order to return c_str from the generic_string, this must remain in memory
101 std::string m_resolved_path;
102};
103
104} // namespace Mantid::Nexus
105
106MANTID_NEXUS_DLL bool operator==(std::string const &s, Mantid::Nexus::NexusAddress const &p);
107
108MANTID_NEXUS_DLL bool operator!=(std::string const &s, Mantid::Nexus::NexusAddress const &p);
109
110MANTID_NEXUS_DLL std::string operator+(std::string const &s, Mantid::Nexus::NexusAddress const &p);
111
112MANTID_NEXUS_DLL std::string operator+(char const s[], Mantid::Nexus::NexusAddress const &p);
113
114MANTID_NEXUS_DLL std::ostream &operator<<(std::ostream &os, Mantid::Nexus::NexusAddress const &p);
MANTID_NEXUS_DLL bool operator!=(std::string const &s, Mantid::Nexus::NexusAddress const &p)
MANTID_NEXUS_DLL std::string operator+(std::string const &s, Mantid::Nexus::NexusAddress const &p)
MANTID_NEXUS_DLL bool operator==(std::string const &s, Mantid::Nexus::NexusAddress const &p)
MANTID_NEXUS_DLL std::ostream & operator<<(std::ostream &os, Mantid::Nexus::NexusAddress const &p)
This simple class encapsulates some methods for working with paths inside a Nexus file.
char const * c_str() const
std::filesystem::path m_path
standard filesystem path
NexusAddress(NexusAddress const &nd)=default
NexusAddress & operator=(NexusAddress const &nd)=default
std::string const & string() const
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Divide two workspaces.
Header for a base Nexus::Exception.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr wide_integer< Bits, Signed > operator+(const wide_integer< Bits, Signed > &lhs) noexcept(is_same< Signed, unsigned >::value)
std::common_type_t< wide_integer< Bits, Signed >, wide_integer< Bits2, Signed2 > > constexpr operator/(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)