Sierra Toolkit Version of the Day
String.hpp File Reference
#include <iosfwd>
#include <string>
Include dependency graph for String.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  sierra::implementation::StringData
class  sierra::StringBase< CT >
class  sierra::char_simple_traits
class  sierra::char_label_traits

Namespaces

namespace  sierra

Typedefs

typedef StringBase
< char_simple_traits > 
sierra::String
typedef StringBase
< char_label_traits > 
sierra::Identifier
typedef StringBase
< char_label_traits > 
sierra::ParamId

Functions

template<class CT1 , class CT2 >
bool sierra::operator== (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 , class CT2 >
bool sierra::operator!= (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 , class CT2 >
bool sierra::operator< (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 , class CT2 >
bool sierra::operator> (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 , class CT2 >
bool sierra::operator<= (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 , class CT2 >
bool sierra::operator>= (const StringBase< CT1 > &, const StringBase< CT2 > &)
template<class CT1 >
bool sierra::operator== (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator!= (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator< (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator> (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator<= (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator>= (const StringBase< CT1 > &, const std::string &)
template<class CT1 >
bool sierra::operator== (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator!= (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator< (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator> (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator<= (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator>= (const StringBase< CT1 > &, const char *)
template<class CT1 >
bool sierra::operator== (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator!= (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator< (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator> (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator<= (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator>= (const char *, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator== (const std::string &, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator!= (const std::string &, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator< (const std::string &, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator> (const std::string &, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator<= (const std::string &, const StringBase< CT1 > &)
template<class CT1 >
bool sierra::operator>= (const std::string &, const StringBase< CT1 > &)
std::ostream & sierra::operator<< (std::ostream &os, const sierra::String &s)
std::istream & sierra::operator>> (std::istream &is, sierra::String &s)
template<class CT , class CT2 >
bool sierra::operator== (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT , class CT2 >
bool sierra::operator!= (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT , class CT2 >
bool sierra::operator< (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT , class CT2 >
bool sierra::operator<= (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT , class CT2 >
bool sierra::operator> (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT , class CT2 >
bool sierra::operator>= (const StringBase< CT > &lhs, const StringBase< CT2 > &rhs)
template<class CT >
bool sierra::operator== (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator!= (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator< (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator<= (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator> (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator>= (const StringBase< CT > &lhs, const std::string &rhs)
template<class CT >
bool sierra::operator== (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator!= (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator< (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator<= (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator> (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator>= (const StringBase< CT > &lhs, const char *rhs)
template<class CT >
bool sierra::operator== (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator!= (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator< (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator<= (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator> (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator>= (const std::string &lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator== (const char *lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator!= (const char *lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator< (const char *lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator<= (const char *lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator> (const char *lhs, const StringBase< CT > &rhs)
template<class CT >
bool sierra::operator>= (const char *lhs, const StringBase< CT > &rhs)
template<class CT , class CT2 >
StringBase< CT > sierra::operator+ (const StringBase< CT > &cs1, const StringBase< CT2 > &cs2)
template<class CT >
StringBase< CT > sierra::operator+ (const StringBase< CT > &cs1, const char *cs2)
template<class CT >
StringBase< CT > sierra::operator+ (const StringBase< CT > &cs1, const std::string &cs2)
template<class CT >
StringBase< CT > sierra::operator+ (const char *cs1, const StringBase< CT > &cs2)
template<class CT >
std::string sierra::operator+ (const std::string &lhs, const StringBase< CT > &rhs)

Detailed Description

Author:
H. Carter Edwards

Simple string value classes that avoid allocation for small strings.

Assumption/Issue

The std::string class (typically) allocates memory to hold any non-zero length string. The ISO C++ interface requirements also define a 'capacity' for std::string that may be larger than the string length. Thus the std::string class must, at a minimum, have a pointer to the allocated memory, a length integer, and a capacity integer. Furthermore, the std::string class may also support reference counting which is another integer. In addition to the std::string overhead there will also be some amount of allocated-memory management overhead. Somewhere between one and four words.

Objective/Policy

In SIERRA numerous object types have 'name' members that are string labels for those objects. These names are typically small, e.g. "density" or "temperature". The objective of the sierra::String class is to minimize the allocated memory overhead associated with these 'name' members.

Design

The String type owns a character buffer that is used to store small strings. If the input string is larger than the buffer then memory is allocated with an allocator (e.g. std::string::allocator_type).

Specification of "small" string

The character buffer is sized to be (1) approximately equal to the overhead of an allocated std::string object and (2) have a 4word (16byte) alignment.

std::string, Interoperability and Recommendations

String constructors and other methods are defined so that objects of the String type can be interoperable with the std::string class. It is recommended that the a final string value for a 'name' or 'label' be stored in a sierra::String object. Long strings or strings that will be manipulated (e.g. insert or append) should use the std::string class. If a name is to be constructed via manipulation then generate the string via 'std::string' and assign the final result to the sierra::String. If string manipulation includes formatting operations then the std::ostringstream or std::istringstream classes should be used.

Definition in file String.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines