ug4
Common Types

Classes

struct  ug::StringTableStream::RepeatedCol
 
class  ug::StringTableStream
 
class  ug::Table< T >
 Useful for printing a table to the terminal or into a file. More...
 
class  ug::Variant
 A variant can represent variables of different types. More...
 

Typedefs

typedef Table< std::stringstream > ug::StringStreamTable
 
typedef Table< std::string > ug::StringTable
 

Functions

template<class TType >
int ug::ArrayEraseEntry (TType *array, const TType &entry, size_t size)
 removes the first occurance of the specified entry. More...
 
template<class TType >
bool ug::ArrayReplaceEntry (TType *array, const TType &newEntry, const TType &oldEntry, size_t size)
 replaces the first occurance of oldEntry with newEntry More...
 
template<class TType >
void ug::ArraySwapWithLast (TType *array, const TType &entry, size_t size)
 Swaps the first entry with the given value with the last entry in the list. More...
 
void ug::StringTableStream::clear ()
 
RepeatedCol ug::StringTableStream::empty_col (size_t i)
 
std::string ug::EntryToString (const Table< std::string > &table, size_t rowInd, size_t colInd)
 
std::string ug::EntryToString (const Table< std::stringstream > &table, size_t rowInd, size_t colInd)
 
template<class T >
std::string ug::EntryToString (const Table< T > &table, size_t rowInd, size_t colInd)
 Returns a string-representation of the current entry. More...
 
StringTableStreamug::StringTableStream::operator<< (const char *c)
 
StringTableStreamug::StringTableStream::operator<< (RepeatedCol c)
 
std::ostream & ug::operator<< (std::ostream &os, const StringTableStream &sts)
 
template<class T >
std::ostream & ug::operator<< (std::ostream &os, const Table< T > &table)
 prints a table to the specified ostream. More...
 
StringTableStreamug::StringTableStream::operator<< (std::string str)
 
template<typename T >
StringTableStreamug::StringTableStream::operator<< (T t)
 
template<typename T >
RepeatedCol ug::StringTableStream::repeat_col (size_t nrRepeat, T contentToRepeat)
 
 ug::StringTableStream::RepeatedCol::RepeatedCol (std::string _content, size_t _number)
 
template<typename T >
void ug::StringTableStream::set (size_t r, size_t c, T t)
 
 ug::StringTableStream::StringTableStream ()
 
StringTableug::StringTableStream::table ()
 
template<>
bool ug::Variant::to () const
 
std::string ug::StringTableStream::to_string () const
 
template<>
Variant::Type ug::Variant::type ()
 
template<>
const std::string & ug::Variant::to< const std::string & > () const
 
template<>
std::string ug::Variant::to< std::string > () const
 
template<>
Variant::Type ug::Variant::type< const std::string & > ()
 
template<>
Variant::Type ug::Variant::type< std::string > ()
 

Variables

std::string ug::StringTableStream::RepeatedCol::content
 
size_t ug::StringTableStream::m_curCol
 
size_t ug::StringTableStream::m_curRow
 
size_t ug::StringTableStream::RepeatedCol::number
 
StringTable ug::StringTableStream::s
 

Detailed Description

Useful for printing a table like a stream to the terminal or into a file.

Typedef Documentation

◆ StringStreamTable

typedef Table<std::stringstream> ug::StringStreamTable

◆ StringTable

typedef Table<std::string> ug::StringTable

Function Documentation

◆ ArrayEraseEntry()

template<class TType >
int ug::ArrayEraseEntry ( TType *  array,
const TType &  entry,
size_t  size 
)

removes the first occurance of the specified entry.

Runs in O(size). copies all entries after the specified one to their predecessor. Be sure that TType supports operator= and operator==

Returns
new size

Referenced by ug::MGEdgeInfo::remove_child(), and ug::MGFaceInfo::remove_child().

◆ ArrayReplaceEntry()

template<class TType >
bool ug::ArrayReplaceEntry ( TType *  array,
const TType &  newEntry,
const TType &  oldEntry,
size_t  size 
)

replaces the first occurance of oldEntry with newEntry

Runs in O(size). Be sure that TType supports operator= and operator==

Returns
true if oldEntry was found, false if not.

Referenced by ug::MGEdgeInfo::replace_child(), ug::MGFaceInfo::replace_child(), and ug::MGVolumeInfo::replace_child().

◆ ArraySwapWithLast()

template<class TType >
void ug::ArraySwapWithLast ( TType *  array,
const TType &  entry,
size_t  size 
)

Swaps the first entry with the given value with the last entry in the list.

Runs in O(size). Iterates through all entries until the given one is found. Be sure that TType supports operator= and operator==

Referenced by ug::MGVolumeInfo::remove_child().

◆ clear()

◆ empty_col()

RepeatedCol ug::StringTableStream::empty_col ( size_t  i)
inline
sts << 1 << "\n";
sts << sts.emtpy_col(1) << 1 << "\n";
sts << sts.empty_col(2) << 1 << "\n";
Definition: string_table_stream.h:66
RepeatedCol empty_col(size_t i)
Definition: string_table_stream.h:156

prints

* 1
*   1
*     1
* 
Parameters
nrRepeatnumber of times to repeat
contentToRepeatwhat to repeat
Returns
RepeatedCol-struct for <<-ing into sts

◆ EntryToString() [1/3]

std::string ug::EntryToString ( const Table< std::string > &  table,
size_t  rowInd,
size_t  colInd 
)
inline

◆ EntryToString() [2/3]

std::string ug::EntryToString ( const Table< std::stringstream > &  table,
size_t  rowInd,
size_t  colInd 
)
inline

◆ EntryToString() [3/3]

template<class T >
std::string ug::EntryToString ( const Table< T > &  table,
size_t  rowInd,
size_t  colInd 
)
inline

Returns a string-representation of the current entry.

The default implementation prints the entry to a std::stringstream and returns the associated string. Specializations exist for std::string and std::stringstream.

Referenced by ug::Table< T >::stream(), and ug::Table< T >::to_csv().

◆ operator<<() [1/6]

StringTableStream& ug::StringTableStream::operator<< ( const char *  c)
inline

operator <<

Parameters
ca const char *. If contains a
, sets curRow++, curCol=0
Returns
*this

References ug::Table< T >::clear(), ug::StringTableStream::m_curCol, ug::StringTableStream::m_curRow, and ug::StringTableStream::s.

◆ operator<<() [2/6]

◆ operator<<() [3/6]

std::ostream& ug::operator<< ( std::ostream &  os,
const StringTableStream sts 
)
inline

◆ operator<<() [4/6]

template<class T >
std::ostream & ug::operator<< ( std::ostream &  os,
const Table< T > &  table 
)

prints a table to the specified ostream.

Assumes that output begins at a new line. The method uses the template method size_t EstimateEntryWidth<T>(const Table<T>& table, size_t rowInd, size_t colInd). You may overload this method to adjust it to your datatypes. Note that specializations exist for std::string and std::stringstream.

Todo:
Support for line-breaks ('
' etc) and multi-line rows.

References ug::Table< T >::stream().

◆ operator<<() [5/6]

StringTableStream& ug::StringTableStream::operator<< ( std::string  str)
inline

◆ operator<<() [6/6]

template<typename T >
StringTableStream& ug::StringTableStream::operator<< ( t)
inline

operator <<. sets curCol++

Parameters
tanything which is ostream << -able
Returns
*this

References ug::StringTableStream::m_curCol, ug::StringTableStream::m_curRow, ug::StringTableStream::s, and ug::ToString().

◆ repeat_col()

template<typename T >
RepeatedCol ug::StringTableStream::repeat_col ( size_t  nrRepeat,
contentToRepeat 
)
inline
sts << 1 << sts.repeat_col(2, 0) << "\n";
sts << 0 << 1 << 0 << "\n";
sts << sts.repeat(2, 0) << 1 << "\n";
RepeatedCol repeat_col(size_t nrRepeat, T contentToRepeat)
Definition: string_table_stream.h:179

prints

* 1 0 0
* 0 1 0
* 0 0 1
* 
Parameters
nrRepeatnumber of times to repeat
contentToRepeatwhat to repeat
Returns
RepeatedCol-struct for <<-ing into sts

References ug::ToString().

◆ RepeatedCol()

ug::StringTableStream::RepeatedCol::RepeatedCol ( std::string  _content,
size_t  _number 
)
inline

◆ set()

template<typename T >
void ug::StringTableStream::set ( size_t  r,
size_t  c,
t 
)
inline

◆ StringTableStream()

ug::StringTableStream::StringTableStream ( )
inline

◆ table()

StringTable& ug::StringTableStream::table ( )
inline

◆ to()

template<>
bool ug::Variant::to ( ) const
inline

◆ to_string()

std::string ug::StringTableStream::to_string ( ) const
inline

◆ type()

template<>
Variant::Type ug::Variant::type ( )
inlinestatic

References ug::Variant::VT_BOOL.

◆ Variant::to< const std::string & >()

template<>
const std::string& ug::Variant::to< const std::string & > ( ) const
inline

◆ Variant::to< std::string >()

template<>
std::string ug::Variant::to< std::string > ( ) const
inline

◆ Variant::type< const std::string & >()

template<>
Variant::Type ug::Variant::type< const std::string & > ( )
inline

◆ Variant::type< std::string >()

template<>
Variant::Type ug::Variant::type< std::string > ( )
inline

Variable Documentation

◆ content

std::string ug::StringTableStream::RepeatedCol::content

◆ m_curCol

size_t ug::StringTableStream::m_curCol
private

◆ m_curRow

size_t ug::StringTableStream::m_curRow
private

◆ number

size_t ug::StringTableStream::RepeatedCol::number

◆ s