39#ifndef LIB_PATH_ARRAY_H
40#define LIB_PATH_ARRAY_H
85 return reinterpret_cast<size_t&
> (p[0]);
96 const char** alloc =
new const char*[siz];
98 return reinterpret_cast<PStorage> (alloc);
113 template<
typename...ELMS>
141 operator bool()
const {
return not
empty(); }
181 auto target =
new const char* [cnt+1];
183 for ( ; pos < target+1+cnt; ++pos)
212 using meta::IndexSeq;
224 template<
size_t chunk_size>
227 static_assert (0 < chunk_size,
"PathArray chunk_size must be nonempty");
243 template<
size_t...prefix,
size_t...rest,
typename...ARGS>
247 :
elms_{pickInit<prefix,
CStr> (forward<ARGS>(args)...) ...}
248 ,
tail_{pickArg<rest> (forward<ARGS>(args)...) ...}
259 template<
typename...ARGS>
267 template<
typename...ARGS>
271 ,typename
Split<ARGS...>::Rest()
272 ,forward<ARGS> (args)...)
303 operator string()
const;
315 Literal* elm = unConst(
this)->getPosition (idx);
319 ,error::LUMIERA_ERROR_INDEX_BOUNDS);
332 if (
elms_.begin() <= &content and &content <
elms_.end())
333 return &content -
elms_.begin();
338 +
" is not located within the storage of PathArray "
358 pos = &src->
tail_[0];
365 ENSURE ( (src->
elms_.begin() <= pos and pos < src->
elms_.end())
394 or (
elms_.begin() <= pos and pos <
elms_.end()
402 while (startPos and isnil (*startPos))
416 while (lastPos != beforeStart and not *lastPos)
432 if (idx < chunk_size)
436 elm = &
tail_[idx-chunk_size];
438 return const_cast<Literal*
> (elm);
448 if (chunk_size <= idx and
size() <= idx)
450 if (idx < chunk_size)
451 return elms_.begin() + idx;
462 *
reinterpret_cast<const char**
> (pos) = val;
468 if (newSize < chunk_size)
473 for ( ; pos!=
end; ++pos)
493 if (
size() == 0)
return;
498 for ( ; pos!=
end; ++pos)
510 for ( ; pos!=
end; ++pos)
523 if (idx >= chunk_size-1)
533 template<
size_t chunk_size>
537 if (this->empty())
return "";
540 size_t expectedLen = this->size() * 10;
541 buff.reserve (expectedLen);
546 size_t len = buff.length();
557 template<
size_t cl,
size_t cr>
561 if (l.
size() != r.
size())
return false;
567 if (*lp != *rp)
return false;
571 return isnil(lp) and isnil(rp);
574 template<
size_t cl,
size_t cr>
Adapter for building an implementation of the »Lumiera Forward Iterator« concept.
Abstraction for path-like topological coordinates.
Literal * getPosition(size_t idx)
size_t indexOf(Literal const &content) const
reverse lookup of actual path content
lib::IterAdapter< Literal const *, PathArray const * > const_iterator
PathArray(PathArray const &)=default
meta::BuildIndexSeq< chunk_size >::Ascending Prefix
iterator firstNonempty() const
std::array< Literal, chunk_size > LiteralArray
meta::BuildIdxIter< ARGS... >::template After< chunk_size > Rest
Literal const & operator[](size_t idx) const
Array style indexed access.
void truncateTo(size_t newSize)
bool isValid(Literal const *pos) const
PathArray(IndexSeq< prefix... >, IndexSeq< rest... >, ARGS &&...args)
friend iterator end(PathArray const &pa)
Literal const * findInlineEnd() const
find effective end of data in the inline array, i.e.
Literal const & const_reference
Literal * expandPosition(size_t idx)
PathArray(ARGS &&...args)
PathArray(PathArray &&)=default
void normalise()
establish the contract of PathArray
PathArray & operator=(PathArray const &)=default
friend bool checkPoint(const PathArray *src, const Literal *&pos)
Implementation of Iteration-logic: detect iteration end.
void setContent(Literal *pos, const char *val)
friend iterator begin(PathArray const &pa)
friend void iterNext(const PathArray *, const Literal *&pos)
Implementation of Iteration-logic: pull next element.
Heap-allocated extension storage for an immutable sequence of literal strings.
Extension & operator=(Extension o)
size_t indexOf(Literal const *pos) const
Extension(Extension &&rr) noexcept
Literal const & operator[](size_t idx) const
bool isValid(Literal const *pos) const
Extension(Extension const &r)
static size_t & size(PStorage &p)
void resizeTo(size_t cnt)
Extension(ELMS &&...elms)
PStorage newCopy() const
allocate a copy.
Lumiera error handling (C++ interface).
Helper template(s) for creating Lumiera Forward Iterators.
Implementation namespace for support and library code.
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
bool operator!=(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
LumieraError< LERR_(INVALID)> Invalid
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
bool isnil(lib::time::Duration const &dur)
Marker types to indicate a literal string and a Symbol.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Metaprogramming with type sequences based on variadic template parameters.