DUECA/DUSIME
Public Member Functions | Public Attributes | List of all members
dueca::Dstring< mxsize > Class Template Reference

This is yet another string class, this time for strings of a fixed maximum size, and therefore a fixed storage requirement. More...

Inheritance diagram for dueca::Dstring< mxsize >:
Inheritance graph
[legend]
Collaboration diagram for dueca::Dstring< mxsize >:
Collaboration graph
[legend]

Public Member Functions

 Dstring ()
 Constructor, makes empty string. More...
 
 Dstring (const char *s)
 Constructor, copies the data from a string. More...
 
 Dstring (const std::string &s)
 Constructor from an std::string.
 
template<int osize>
 Dstring (const Dstring< osize > &o)
 Copy constructor. More...
 
 Dstring (AmorphReStore &s)
 Construct the string from amorphous storage. More...
 
Dstringoperator= (const char *s)
 Assignment operator. More...
 
Dstringoperator= (const string &o)
 Assignment operator with string. More...
 
template<int osize>
Dstringoperator= (const Dstring< osize > &o)
 Assignment operator with a Dstring of the same or some other size. More...
 
template<int osize>
Dstring operator+ (const Dstring< osize > &s)
 Append a string to this one. More...
 
Dstring operator+ (const char *s)
 Append a c-style string to this one. More...
 
bool operator== (const Dstring< mxsize > &o) const
 Returns true if two strings are equal. More...
 
bool operator!= (const Dstring< mxsize > &o) const
 Returns false if two strings are equal. More...
 
bool operator< (const Dstring< mxsize > &o) const
 Returns true if lexically smaller than second string.
 
bool operator> (const Dstring< mxsize > &o) const
 Returns true if lexically greater than second string.
 
const char * c_str () const
 Get the c-string style data out. More...
 
void assign (const char *d, size_t size)
 grab from a buffer
 
size_t size () const
 Get the length of the string. More...
 
constexpr size_t max_size () const
 Maximum size.
 
void resize (size_t s)
 Resize.
 
const char * getData () const
 Get direct access to the underlying data. More...
 
const char * data () const
 Get direct access to the underlying data. More...
 
const char * begin () const
 Pointer to the start.
 
char * begin ()
 Pointer to the start.
 
const char * end () const
 Pointer to the end.
 
char * end ()
 Pointer to the end.
 
char * data ()
 Get direct access to the underlying data. More...
 
void packData (AmorphStore &s) const
 Pack the string into a net-transportable format. More...
 
void unPackData (AmorphReStore &s)
 Unpack the string from a net-transportable format. More...
 
std::ostream & print (std::ostream &os) const
 Print to a stream. More...
 
std::istream & read (std::istream &is)
 Read from a stream. More...
 

Public Attributes

char _data [mxsize]
 The actual data, as a c-type string. More...
 

Additional Inherited Members

- Static Public Attributes inherited from dueca::dstring
static const char * classname
 Object is packable, and therefore its name is needed.
 
- Protected Member Functions inherited from dueca::dstring
 dstring ()
 Constructor. More...
 

Detailed Description

template<unsigned mxsize>
class dueca::Dstring< mxsize >

This is yet another string class, this time for strings of a fixed maximum size, and therefore a fixed storage requirement.

Constructor & Destructor Documentation

◆ Dstring() [1/4]

template<unsigned mxsize>
dueca::Dstring< mxsize >::Dstring ( )

Constructor, makes empty string.

◆ Dstring() [2/4]

template<unsigned mxsize>
dueca::Dstring< mxsize >::Dstring ( const char *  s)

Constructor, copies the data from a string.

◆ Dstring() [3/4]

template<unsigned mxsize>
template<int osize>
dueca::Dstring< mxsize >::Dstring ( const Dstring< osize > &  o)
inline

Copy constructor.

Should be used for a brother/sister dstring of different size.

◆ Dstring() [4/4]

template<unsigned mxsize>
dueca::Dstring< mxsize >::Dstring ( AmorphReStore s)

Construct the string from amorphous storage.

Member Function Documentation

◆ operator=() [1/3]

template<unsigned mxsize>
Dstring& dueca::Dstring< mxsize >::operator= ( const char *  s)

Assignment operator.

◆ operator=() [2/3]

template<unsigned mxsize>
Dstring& dueca::Dstring< mxsize >::operator= ( const string &  o)
inline

Assignment operator with string.

◆ operator=() [3/3]

template<unsigned mxsize>
template<int osize>
Dstring& dueca::Dstring< mxsize >::operator= ( const Dstring< osize > &  o)
inline

Assignment operator with a Dstring of the same or some other size.

◆ operator+() [1/2]

template<unsigned mxsize>
template<int osize>
Dstring dueca::Dstring< mxsize >::operator+ ( const Dstring< osize > &  s)
inline

Append a string to this one.

Note that truncation may result.

◆ operator+() [2/2]

template<unsigned mxsize>
Dstring dueca::Dstring< mxsize >::operator+ ( const char *  s)

Append a c-style string to this one.

Note that truncation may result.

◆ operator==()

template<unsigned mxsize>
bool dueca::Dstring< mxsize >::operator== ( const Dstring< mxsize > &  o) const

Returns true if two strings are equal.

◆ operator!=()

template<unsigned mxsize>
bool dueca::Dstring< mxsize >::operator!= ( const Dstring< mxsize > &  o) const

Returns false if two strings are equal.

◆ c_str()

template<unsigned mxsize>
const char* dueca::Dstring< mxsize >::c_str ( ) const
inline

Get the c-string style data out.

◆ size()

template<unsigned mxsize>
size_t dueca::Dstring< mxsize >::size ( ) const

Get the length of the string.

◆ getData()

template<unsigned mxsize>
const char* dueca::Dstring< mxsize >::getData ( ) const
inline

Get direct access to the underlying data.

◆ data() [1/2]

template<unsigned mxsize>
const char* dueca::Dstring< mxsize >::data ( ) const
inline

Get direct access to the underlying data.

◆ data() [2/2]

template<unsigned mxsize>
char* dueca::Dstring< mxsize >::data ( )
inline

Get direct access to the underlying data.

◆ packData()

template<unsigned mxsize>
void dueca::Dstring< mxsize >::packData ( AmorphStore s) const

Pack the string into a net-transportable format.

◆ unPackData()

template<unsigned mxsize>
void dueca::Dstring< mxsize >::unPackData ( AmorphReStore s)

Unpack the string from a net-transportable format.

◆ print()

template<unsigned mxsize>
std::ostream& dueca::Dstring< mxsize >::print ( std::ostream &  os) const

Print to a stream.

◆ read()

template<unsigned mxsize>
std::istream& dueca::Dstring< mxsize >::read ( std::istream &  is)

Read from a stream.

Todo:
implement and check.

Member Data Documentation

◆ _data

template<unsigned mxsize>
char dueca::Dstring< mxsize >::_data[mxsize]

The actual data, as a c-type string.


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