PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIConfig::Branch Class Reference

Branch class - container for Entry objects. More...

#include <piconfig.h>

Inheritance diagram for PIConfig::Branch:
Inheritance graph
[legend]

Public Member Functions

EntrygetValue (const PIString &vname, const PIString &def=PIString(), bool *exists=0)
 Get value from branch by name with default value. More...
 
EntrygetValue (const PIString &vname, const char *def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const PIStringList &def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const bool def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const short def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const int def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const long def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const uchar def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const ushort def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const uint def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const ulong def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const float def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
EntrygetValue (const PIString &vname, const double def, bool *exists=0)
 Get entry with name "vname" and default value "def".
 
Branch allLeaves ()
 Returns all leaf descendants reachable from this branch.
 
Branch getValues (const PIString &name)
 Get all entries with name containing specified substring.
 
Branch getLeaves ()
 Returns only entries in this branch that have no children.
 
Branch getBranches ()
 Returns only entries in this branch that have children.
 
Branchfilter (const PIString &f)
 Removes entries whose names do not contain "f".
 
bool isEntryExists (const PIString &name) const
 Returns true if any entry in this branch or its descendants has name "name".
 
int indexOf (const Entry *e)
 Returns position of entry pointer "e" inside this branch, or -1.
 
- Public Member Functions inherited from PIVector< Entry * >
 PIVector ()
 Constructs an empty array.
 
 PIVector (const Entry * *data, size_t size)
 Contructs array from raw data. This constructor reserve size and copy from data pointer.
 
 PIVector (const PIVector< Entry * > &v)
 Copy constructor.
 
 PIVector (std::initializer_list< Entry * > init_list)
 Contructs array from C++11 initializer list. More...
 
 PIVector (size_t size, const Entry * &e=Entry *())
 Contructs array with size size filled elements e.
 
 PIVector (size_t size, std::function< Entry *(size_t i)> f)
 Contructs array with size size and elements created by function f(size_t i). More...
 
 PIVector (PIVector< Entry * > &&v)
 Move constructor.
 
PIVector< Entry * > & operator= (const PIVector< Entry * > &v)
 Assign operator.
 
PIVector< Entry * > & operator= (PIVector< Entry * > &&v)
 Assign move operator.
 
iterator begin ()
 Iterator to the first element. More...
 
iterator end ()
 Iterator to the element following the last element. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the first element of the reversed array. More...
 
reverse_iterator rend ()
 Returns a reverse iterator to the element following the last element of the reversed array. More...
 
size_t size () const
 Number of elements in the container. More...
 
ssize_t size_s () const
 Number of elements in the container as signed value. More...
 
size_t length () const
 Same as size(). More...
 
size_t capacity () const
 Number of elements that the container has currently allocated space for. More...
 
bool isEmpty () const
 Checks if the container has no elements. More...
 
bool isNotEmpty () const
 Checks if the container has elements. More...
 
bool any (std::function< bool(const Entry * &e)> test) const
 Tests whether at least one element in the array passes the test implemented by the provided function test. More...
 
bool every (std::function< bool(const Entry * &e)> test) const
 Tests whether all elements in the array passes the test implemented by the provided function test. More...
 
Entry * & operator[] (size_t index)
 Full access to element by index. More...
 
const Entry * & at (size_t index) const
 Read only access to element by index. More...
 
const Entry * & atWhere (std::function< bool(const Entry * &e)> test, ssize_t start=0, const Entry * &def=Entry *()) const
 Returns the first element of the array that passes the test implemented by the provided function test or def if there is no such element. More...
 
const Entry * & lastAtWhere (std::function< bool(const Entry * &e)> test, ssize_t start=-1, const Entry * &def=Entry *()) const
 Returns the last element of the array that passes the test implemented by the provided function test or def if there is no such element. More...
 
Entry * & back ()
 Last element. More...
 
Entry * & front ()
 Last element. More...
 
bool operator== (const PIVector< Entry * > &v) const
 Compare operator with array v.
 
bool operator!= (const PIVector< Entry * > &v) const
 Compare operator with array v.
 
bool contains (const Entry * &e, ssize_t start=0) const
 Tests if element e exists in the array. More...
 
bool containsAll (const PIVector< Entry * > &v, ssize_t start=0) const
 Tests if all elements of v exists in the array. More...
 
bool containsAny (const PIVector< Entry * > &v, ssize_t start=0) const
 Tests if any element of v exists in the array. More...
 
int entries (const Entry * &e, ssize_t start=0) const
 Count elements equal e in the array. More...
 
int entries (std::function< bool(const Entry * &e)> test, ssize_t start=0) const
 Count elements in the array passes the test implemented by the provided function test. More...
 
ssize_t indexOf (const Entry * &e, ssize_t start=0) const
 Returns the first index at which a given element e can be found in the array, or -1 if it is not present. More...
 
ssize_t indexWhere (std::function< bool(const Entry * &e)> test, ssize_t start=0) const
 Returns the first index passes the test implemented by the provided function test, or -1 if it is not present. can be found in the array, or -1 if it is not present. More...
 
ssize_t lastIndexOf (const Entry * &e, ssize_t start=-1) const
 Returns the last index at which a given element e can be found in the array, or -1 if it is not present. More...
 
ssize_t lastIndexWhere (std::function< bool(const Entry * &e)> test, ssize_t start=-1) const
 Returns the last index passes the test implemented by the provided function test, or -1 if it is not present. More...
 
Entry * * data (size_t index=0)
 Pointer to array. More...
 
const Entry * * data (size_t index=0) const
 Read only pointer to array. More...
 
PIVector< Entry * > getRange (size_t index, size_t count) const
 Creates sub-array of this array. More...
 
PIVector< Entry * > & clear ()
 Clear array, remove all elements. More...
 
PIVector< Entry * > & fill (const Entry * &e=Entry *())
 Assigns element 'e' to all items in the array. More...
 
PIVector< Entry * > & fill (std::function< Entry *(size_t i)> f)
 Assigns result of function 'f(size_t i)' to all items in the array. More...
 
PIVector< Entry * > & assign (const Entry * &e=Entry *())
 Same as fill(). More...
 
PIVector< Entry * > & assign (size_t new_size, const Entry * &f)
 First does resize(new_size) then fill(e). More...
 
PIVector< Entry * > & resize (size_t new_size, const Entry * &e=Entry *())
 Sets size of the array, new elements are copied from e. More...
 
PIVector< Entry * > & resize (size_t new_size, std::function< Entry *(size_t i)> f)
 Sets size of the array, new elements created by function f(size_t i). More...
 
PIVector< Entry * > & reserve (size_t new_size)
 Attempts to allocate memory for at least new_size elements. More...
 
PIVector< Entry * > & insert (size_t index, const Entry * &e=Entry *(), size_t count=1)
 Inserts value e at index position in the array. More...
 
PIVector< Entry * > & insert (size_t index, Entry * &&e)
 Inserts value e at index position in the array. More...
 
PIVector< Entry * > & insert (size_t index, const PIVector< Entry * > &v)
 Inserts array v at index position in the array. More...
 
PIVector< Entry * > & insert (size_t index, std::initializer_list< Entry * > init_list)
 Inserts the given elements at index position in the array. More...
 
PIVector< Entry * > & remove (size_t index, size_t count=1)
 Removes count elements from the middle of the array, starting at index position. More...
 
void swap (PIVector< Entry * > &v)
 Swaps array v other with this array. More...
 
PIVector< Entry * > & sort ()
 Sorts the elements in non-descending order. More...
 
PIVector< Entry * > & sort (std::function< bool(const Entry * &a, const Entry * &b)> comp)
 Sorts the elements in non-descending order. More...
 
PIVector< Entry * > & reverse ()
 Reverses this array. More...
 
PIVector< Entry * > reversed () const
 Returns reversed array. More...
 
PIVector< Entry * > & enlarge (ssize_t add_size, const Entry * &e=Entry *())
 Increases or decreases the size of the array by add_size elements. More...
 
PIVector< Entry * > & removeOne (const Entry * &e)
 Remove no more than one element equal e. More...
 
PIVector< Entry * > & removeAll (const Entry * &e)
 Remove all elements equal e. More...
 
PIVector< Entry * > & removeWhere (std::function< bool(const Entry * &e)> test)
 Remove all elements in the array passes the test implemented by the provided function test. More...
 
PIVector< Entry * > & push_back (const Entry * &e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & push_back (Entry * &&e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & push_back (std::initializer_list< Entry * > init_list)
 Appends the given elements to the end of the array. More...
 
PIVector< Entry * > & push_back (const PIVector< Entry * > &v)
 Appends the given array v to the end of the array. More...
 
PIVector< Entry * > & append (const Entry * &e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & append (Entry * &&e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & append (std::initializer_list< Entry * > init_list)
 Appends the given elements to the end of the array. More...
 
PIVector< Entry * > & append (const PIVector< Entry * > &v)
 Appends the given array v to the end of the array. More...
 
PIVector< Entry * > & operator<< (const Entry * &e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & operator<< (Entry * &&e)
 Appends the given element e to the end of the array. More...
 
PIVector< Entry * > & operator<< (const PIVector< Entry * > &v)
 Appends the given array v to the end of the array. More...
 
PIVector< Entry * > & push_front (const Entry * &e)
 Appends the given element e to the begin of the array. More...
 
PIVector< Entry * > & push_front (Entry * &&e)
 Appends the given element e to the begin of the array. More...
 
PIVector< Entry * > & push_front (const PIVector< Entry * > &v)
 Appends the given array v to the begin of the array. More...
 
PIVector< Entry * > & push_front (std::initializer_list< Entry * > init_list)
 Appends the given elements to the begin of the array. More...
 
PIVector< Entry * > & prepend (const Entry * &e)
 Appends the given element e to the begin of the array. More...
 
PIVector< Entry * > & prepend (Entry * &&e)
 Appends the given element e to the begin of the array. More...
 
PIVector< Entry * > & prepend (const PIVector< Entry * > &v)
 Appends the given array v to the begin of the array. More...
 
PIVector< Entry * > & prepend (std::initializer_list< Entry * > init_list)
 Appends the given elements to the begin of the array. More...
 
PIVector< Entry * > & pop_back ()
 Remove one element from the end of the array. More...
 
PIVector< Entry * > & pop_front ()
 Remove one element from the begining of the array. More...
 
Entry * take_back ()
 Remove one element from the end of the array and return it. More...
 
Entry * take_front ()
 Remove one element from the begining of the array and return it. More...
 
PIVector< ST > toType () const
 Returns an array converted to another type. More...
 
PIVector< Entry * > filter (std::function< bool(const Entry * &e)> test) const
 Returns a new array with all elements that pass the test implemented by the provided function bool test(const T & e). More...
 
PIVector< Entry * > filterIndexed (std::function< bool(size_t index, const Entry * &e)> test) const
 Same as filter() but with index parameter in test. More...
 
PIVector< Entry * > filterReverse (std::function< bool(const Entry * &e)> test) const
 Same as filter() but from end to begin (from right to left). More...
 
PIVector< Entry * > filterReverseIndexed (std::function< bool(size_t index, const Entry * &e)> test) const
 Same as filterReverse() but with index parameter in test. More...
 
void forEach (std::function< void(const Entry * &e)> f) const
 Execute function void f(const T & e) for every element in array. More...
 
PIVector< Entry * > & forEach (std::function< void(Entry * &e)> f)
 Execute function void f(T & e) for every element in array. More...
 
void forEachIndexed (std::function< void(size_t index, const Entry * &e)> f) const
 Same as forEach() but with index parameter in f. More...
 
PIVector< Entry * > & forEachIndexed (std::function< void(size_t index, Entry * &e)> f)
 Same as forEachIndexed(), but allows you to change the elements of the array. More...
 
void forEachReverse (std::function< void(const Entry * &e)> f) const
 Same as forEach() but from end to begin (from right to left). More...
 
PIVector< Entry * > & forEachReverse (std::function< void(Entry * &e)> f)
 Same as forEachReverse(), but allows you to change the elements of the array. More...
 
void forEachReverseIndexed (std::function< void(size_t index, const Entry * &e)> f) const
 Same as forEachIndexed() but from end to begin (from right to left). More...
 
PIVector< Entry * > & forEachReverseIndexed (std::function< void(size_t index, Entry * &e)> f)
 Same as forEachReverseIndexed(), but allows you to change the elements of the array. More...
 
PIVector< ST > map (std::function< ST(const Entry * &e)> f) const
 Сreates a new array populated with the results of calling a provided function ST f(const T & e) on every element in the calling array. More...
 
PIVector< ST > mapIndexed (std::function< ST(size_t index, const Entry * &e)> f) const
 Same as map() but with index parameter in f. More...
 
PIVector< ST > mapReverse (std::function< ST(const Entry * &e)> f) const
 Same as map() but from end to begin (from right to left). More...
 
PIVector< ST > mapReverseIndexed (std::function< ST(size_t index, const Entry * &e)> f) const
 Same as mapReverse() but with index parameter in f. More...
 
ST reduce (std::function< ST(const Entry * &e, const ST &acc)> f, const ST &initial=ST()) const
 Applies the function ST f(const T & e, const ST & acc) to each element of the array (from left to right), returns one value. More...
 
ST reduceIndexed (std::function< ST(size_t index, const Entry * &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduce() but with index parameter in f. More...
 
ST reduceReverse (std::function< ST(const Entry * &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduce() but from end to begin (from right to left). More...
 
ST reduceReverseIndexed (std::function< ST(size_t index, const Entry * &e, const ST &acc)> f, const ST &initial=ST()) const
 Same as reduceReverse() but with index parameter in f. More...
 
PIVector< PIVector< Entry * > > reshape (size_t rows, size_t cols, ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the array, creates a two-dimensional array from a one-dimensional array. More...
 
PIVector< PIVector< C > > reshape (size_t rows, size_t cols, ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the two-dimensional array. More...
 
PIVector< C > flatten (ReshapeOrder order=ReshapeByRow) const
 Changes the dimension of the array, creates a one-dimensional array from a two-dimensional array. More...
 
PIVector< PIVector< Entry * > > split (const Entry * &separator) const
 Divides an array into a two-dimensional array using the separator separator. More...
 
PIVector< PIVector< Entry * > > splitBySize (size_t sz) const
 Divides an array into a two-dimensional array in chunks of no more than sz. More...
 
PIVector< Entry * > takeRange (size_t index, size_t count)
 Cut sub-array of this array. More...
 

Detailed Description

Branch class - container for Entry objects.

Branch is a list of entries of configuration file

Branch provides some features to get entries lists.

Member Function Documentation

◆ getValue()

PIConfig::Entry & PIConfig::Branch::getValue ( const PIString vname,
const PIString def = PIString(),
bool *  exists = 0 
)

Get value from branch by name with default value.

If lookup fails, returns a shared default entry filled with "def" and sets exists to false when provided.