Lumiera  0.pre.03
»edit your freedom«
PathArray< chunk_size > Class Template Reference

#include "lib/path-array.hpp"

Description

template<size_t chunk_size>
class lib::PathArray< chunk_size >

Abstraction for path-like topological coordinates.

A sequence of Literal strings, with array-like access and standard iteration. Implemented as fixed size inline tuple with heap allocated unlimited extension space.

Note
contents are normalised on initialisation
  • leading empty elements are filled with Symbol::EMPTY
  • empty elements in the middle are replaced by "*"
  • trailing empty elements and "*" are trimmed

Definition at line 251 of file path-array.hpp.

Public Types

using const_iterator = lib::IterAdapter< Literal const *, PathArray const * >
 
using const_reference = Literal const &
 
using iterator = const_iterator
 
using reference = Literal &
 
using value_type = Literal
 

Public Member Functions

template<typename... ARGS>
 PathArray (ARGS &&...args)
 
 PathArray (PathArray &&)=default
 
 PathArray (PathArray const &)=default
 
 PathArray (PathArray &o)
 
iterator begin () const
 
bool empty () const
 
iterator end () const
 
size_t indexOf (Literal const &content) const
 reverse lookup of actual path content More...
 
size_t leafLevel () const
 
 operator string () const
 joins nonempty content, separated by slash
 
PathArrayoperator= (PathArray const &)=default
 
PathArrayoperator= (PathArray &&)=default
 
Literal const & operator[] (size_t idx) const
 Array style indexed access. More...
 
size_t size () const
 

Classes

struct  Split
 

Friends

iterator begin (PathArray const &pa)
 
bool checkPoint (const PathArray *src, const Literal *&pos)
 Implementation of Iteration-logic: detect iteration end. More...
 
iterator end (PathArray const &pa)
 
void iterNext (const PathArray *, const Literal *&pos)
 Implementation of Iteration-logic: pull next element. More...
 

Protected Member Functions

LiteralexpandPosition (size_t idx)
 
LiteralgetPosition (size_t idx)
 
void normalise ()
 establish the contract of PathArray More...
 
void setContent (Literal *pos, const char *val)
 
void truncateTo (size_t newSize)
 

Private Types

using CcP = const char *
 
using LiteralArray = std::array< Literal, chunk_size >
 

Private Member Functions

template<size_t... prefix, size_t... rest, typename... ARGS>
 PathArray (IndexSeq< prefix... >, IndexSeq< rest... >, ARGS &&...args)
 
Literal const * findInlineEnd () const
 find effective end of data in the inline array, i.e. More...
 
iterator firstNonempty () const
 
bool isValid (Literal const *pos) const
 

Private Attributes

LiteralArray elms_
 
con::Extension tail_
 

Class Documentation

◆ lib::PathArray::Split

struct lib::PathArray::Split
Class Members
typedef typename BuildIndexSeq
< chunk_size >::Ascending
Prefix
Rest
+ Collaboration diagram for PathArray< chunk_size >::Split< ARGS >:

Constructor & Destructor Documentation

◆ PathArray()

PathArray ( IndexSeq< prefix... >  ,
IndexSeq< rest... >  ,
ARGS &&...  args 
)
inlineprivate

delegate ctor to place the initialiser arguments appropriately

Remarks
the two index sequences passed by pattern match determine which arguments go to the inline array, and which go to heap allocated extension. The inline array has fixed size an is thus filled with trailing NULL ptrs, which is achieved with the help of meta::pickInit(). The con::Extension is an embedded smart-ptr, which, when receiving additional tail arguments, will place and manage them within a heap allocated array.

Definition at line 271 of file path-array.hpp.

Member Function Documentation

◆ operator[]()

Literal const& operator[] ( size_t  idx) const
inline

Array style indexed access.

Exceptions
error::Invalidon bound violation
Returns
reference to the normalised content
Note
returns Symbol::EMPTY for leading empty elements, even while iteration will skip such entries.

Definition at line 340 of file path-array.hpp.

◆ indexOf()

size_t indexOf ( Literal const &  content) const
inline

reverse lookup of actual path content

Parameters
contentreference to actual content residing within the path
Returns
index position of the content within the path
Exceptions
error::Invalidwhen the given storage location is outside the data content storage of this path

Definition at line 357 of file path-array.hpp.

Referenced by UICoordResolver::extend().

+ Here is the caller graph for this function:

◆ begin()

iterator begin ( ) const
inline
Remarks
iteration is defined to begin with real content

Definition at line 406 of file path-array.hpp.

Referenced by PathArray< UIC_INLINE_SIZE >::begin(), UICoordResolver::extend(), and lib::operator==().

+ Here is the caller graph for this function:

◆ findInlineEnd()

Literal const* findInlineEnd ( ) const
inlineprivate

find effective end of data in the inline array, i.e.

the position behind the last usable content

Definition at line 439 of file path-array.hpp.

◆ getPosition()

Literal* getPosition ( size_t  idx)
inlineprotected

access content element by index

Returns
pointer to storage, null if out of bounds

Definition at line 456 of file path-array.hpp.

◆ expandPosition()

Literal* expandPosition ( size_t  idx)
inlineprotected

ensure storage for the indicated position exists

Returns
pointer to the storage, either existing or reallocated

Definition at line 473 of file path-array.hpp.

Referenced by UICoord::Builder::truncateTo().

+ Here is the caller graph for this function:

◆ setContent()

void setContent ( Literal pos,
const char *  val 
)
inlineprotected

force new content into the given entry

Definition at line 486 of file path-array.hpp.

Referenced by UICoord::Builder::truncateTo().

+ Here is the caller graph for this function:

◆ normalise()

void normalise ( )
inlineprotected

establish the contract of PathArray

  • no null pointer within the valid storage range
  • storage is precisely trimmed at the end
  • missing leading elements are filled with Symbol::EMPTY
  • missing inner elements are interpolated as "*"

Definition at line 518 of file path-array.hpp.

Referenced by UICoord::Builder::truncateTo().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ iterNext

void iterNext ( const PathArray< chunk_size > *  ,
const Literal *&  pos 
)
friend

Implementation of Iteration-logic: pull next element.

Definition at line 374 of file path-array.hpp.

◆ checkPoint

bool checkPoint ( const PathArray< chunk_size > *  src,
const Literal *&  pos 
)
friend

Implementation of Iteration-logic: detect iteration end.

Definition at line 381 of file path-array.hpp.

+ Inheritance diagram for PathArray< chunk_size >:
+ Collaboration diagram for PathArray< chunk_size >:

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