AGX Dynamics  2.35.0.1
Path.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_PATH_H
18 #define AGX_PATH_H
19 
20 #include <agx/Name.h>
21 #include <agx/HashFunction.h>
22 
23 #ifdef _MSC_VER
24 # pragma warning(push)
25 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
26 #endif
27 
28 namespace agx
29 {
34  {
35  public:
36  Path();
37  Path(const agx::String& path);
38  Path(const std::string& path);
39  Path(const char *path);
40  // Path(const char *begin, const char *end);
41  Path(const agx::Path& other);
42  explicit Path(const Name& name);
43 
44  ~Path();
45 
46  Path& operator= (const Path& other);
47 
48 
52  const agx::String& str() const;
53 
57  const char *c_str() const;
58 
62  agx::String root() const;
63 
67  bool empty() const;
68 
72  bool hasTail() const;
73 
77  agx::Path tail() const;
78 
82  agx::Path base() const;
83 
87  agx::String back() const;
88 
89 
90  bool contains(const Path& subpath);
91  bool contains(const Name& component);
92 
93  // Hash function
94  UInt32 hash() const;
95 
96  agx::Path operator+ (const agx::Path& extension) const;
97  agx::Path operator+ (const agx::Name& extension) const;
98 
99  agx::Path& operator+= (const agx::Path& extension);
100  agx::Path& operator+= (const agx::Name& extension);
101 
102  bool operator== (const agx::Path& other) const;
103  bool operator!= (const agx::Path& other) const;
104 
105 
106  public:
108  {
109  public:
111 
113 
116 
117  bool operator== (const iterator& other) const;
118  bool operator!= (const iterator& other) const;
119 
120  private:
121  friend class Path;
122  iterator(const Path& path, size_t pos = 0);
123 
124  private:
125  String m_path;
126  size_t m_pos;
127  };
128 
129 
130  iterator begin() const;
131  iterator end() const;
132 
133  private:
134  void init(const char *begin, const char *end);
135  void init(const std::string& str);
136 
137  private:
138  String m_str;
139  };
140 
141 
142  AGXCORE_EXPORT std::ostream& operator << ( std::ostream& stream, const Path& path );
143 
144  /* Implementation */
145  inline Path::Path()
146  {}
147 
148  AGX_FORCE_INLINE const String& Path::str() const { return m_str; }
149 
150  inline Path::iterator Path::begin() const { return iterator(*this); }
151  inline Path::iterator Path::end() const { return iterator(*this, String::npos); }
152 
154  {
155  return agx::hash(m_str);
156  }
157 
158 }
159 
160 #ifdef _MSC_VER
161 # pragma warning(pop)
162 #endif
163 
164 #endif /* AGX_PATH_H */
#define AGXCORE_EXPORT
Representation of a name string.
Definition: Name.h:33
iterator operator++(int)
iterator & operator++()
Representation of a path, a list of name components.
Definition: Path.h:34
Path(const agx::String &path)
Path(const std::string &path)
Path(const char *path)
Path(const Name &name)
agx::Path tail() const
Path()
Definition: Path.h:145
UInt32 hash() const
Definition: Path.h:153
agx::String root() const
const agx::String & str() const
Definition: Path.h:148
iterator end() const
Definition: Path.h:151
iterator begin() const
Definition: Path.h:150
bool contains(const Name &component)
bool hasTail() const
agx::String back() const
bool contains(const Path &subpath)
agx::Path base() const
const char * c_str() const
bool empty() const
Path(const agx::Path &other)
#define AGX_FORCE_INLINE
Definition: macros.h:58
AGXCABLE_EXPORT SegmentDamage & operator+=(SegmentDamage &lhs, const SegmentDamage &rhs)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AgXString< T > operator+(const Indentation &indentation, const AgXString< T > &str)
Definition: Indentation.h:66
uint32_t UInt32
Definition: Integer.h:40
AGXCORE_EXPORT UInt32 hash(const T &key)
Definition: HashFunction.h:65
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
bool operator!=(T val, InvalidIndexStruct)
Definition: agx.h:196
bool operator==(T val, InvalidIndexStruct)
Definition: agx.h:190
Vec3T< T > operator*(const Vec3T< T > &v, const AffineMatrix4x4T< T > &m)
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
std::ostream & operator<<(std::ostream &stream, const AtomicValueT< T > &value)
Definition: AtomicValue.h:109
void AGXPHYSICS_EXPORT init()
Initialize agx.