KiCad PCB EDA Suite
KIID_PATH Class Reference

#include <kiid.h>

Inheritance diagram for KIID_PATH:

Public Member Functions

 KIID_PATH ()
 
 KIID_PATH (const wxString &aString)
 
bool MakeRelativeTo (const KIID_PATH &aPath)
 
wxString AsString () const
 
bool operator== (KIID_PATH const &rhs) const
 
bool operator< (KIID_PATH const &rhs) const
 

Detailed Description

Definition at line 107 of file kiid.h.

Constructor & Destructor Documentation

◆ KIID_PATH() [1/2]

KIID_PATH::KIID_PATH ( )
inline

Definition at line 110 of file kiid.h.

111  {
112  }

◆ KIID_PATH() [2/2]

KIID_PATH::KIID_PATH ( const wxString &  aString)

Definition at line 246 of file kiid.cpp.

247 {
248  for( const wxString& pathStep : wxSplit( aString, '/' ) )
249  {
250  if( !pathStep.empty() )
251  emplace_back( KIID( pathStep ) );
252  }
253 }
Definition: kiid.h:44

Member Function Documentation

◆ AsString()

◆ MakeRelativeTo()

bool KIID_PATH::MakeRelativeTo ( const KIID_PATH aPath)

Definition at line 256 of file kiid.cpp.

257 {
258  KIID_PATH copy = *this;
259  clear();
260 
261  if( aPath.size() > copy.size() )
262  return false; // this path is not contained within aPath
263 
264  for( size_t i = 0; i < aPath.size(); ++i )
265  {
266  if( copy.at( i ).AsString() != aPath.at( i ).AsString() )
267  return false; // this path is not contained within aPath
268  }
269 
270  for( size_t i = aPath.size(); i < copy.size(); ++i )
271  push_back( copy.at( i ) );
272 
273  return true;
274 }
wxString AsString() const
Definition: kiid.cpp:277

References AsString(), and copy.

◆ operator<()

bool KIID_PATH::operator< ( KIID_PATH const &  rhs) const
inline

Definition at line 134 of file kiid.h.

135  {
136  if( size() != rhs.size() )
137  return size() < rhs.size();
138 
139  for( size_t i = 0; i < size(); ++i )
140  {
141  if( at( i ) < rhs.at( i ) )
142  return true;
143 
144  if( at( i ) != rhs.at( i ) )
145  return false;
146  }
147 
148  return false;
149  }

◆ operator==()

bool KIID_PATH::operator== ( KIID_PATH const &  rhs) const
inline

Definition at line 120 of file kiid.h.

121  {
122  if( size() != rhs.size() )
123  return false;
124 
125  for( size_t i = 0; i < size(); ++i )
126  {
127  if( at( i ) != rhs.at( i ) )
128  return false;
129  }
130 
131  return true;
132  }

The documentation for this class was generated from the following files: