libfoedus-core
FOEDUS Core Library
|
An embedded string object of fixed max-length, which uses no external memory. More...
An embedded string object of fixed max-length, which uses no external memory.
This header-only object behaves like std::string in many ways. The key difference is that this object is essentially a fixed array while std::string allocates memory in heap (with some exception for optimized stack-allocation, but that's not the point).
This implies a few crucial characteristics.
As mentioned above, this object is used where we can't use std::string that points to somewhere else. For example, use it as follows.
No char traits for exotic comparison rules. Not more than 2^32-1 chars. Length 2^32-1 is reserved for npos.
Definition at line 65 of file fixed_string.hpp.
#include <fixed_string.hpp>
Public Member Functions | |
FixedString () noexcept | |
Constructs an empty string. More... | |
template<uint MAXLEN2> | |
FixedString (const FixedString< MAXLEN2, CHAR > &other) noexcept | |
Copy constructor for all FixedString objects. More... | |
FixedString (const CHAR *str, uint32_t len) noexcept | |
Copy constructor for char* and len. More... | |
FixedString (const CHAR *str) noexcept | |
Copy constructor for null-terminated char*. More... | |
template<uint MAXLEN2> | |
FixedString & | operator= (const FixedString< MAXLEN2, CHAR > &other) noexcept |
Assign operator for all FixedString objects. More... | |
template<uint MAXLEN2> | |
bool | operator== (const FixedString< MAXLEN2, CHAR > &other) const noexcept |
template<uint MAXLEN2> | |
bool | operator!= (const FixedString< MAXLEN2, CHAR > &other) const noexcept |
template<uint MAXLEN2> | |
bool | operator< (const FixedString< MAXLEN2, CHAR > &other) const noexcept |
template<uint MAXLEN2> | |
void | assign (const FixedString< MAXLEN2, CHAR > &other) noexcept |
Assign operator for all FixedString objects. More... | |
void | assign (const std::basic_string< CHAR > &str) noexcept |
Assign operator for std::string. More... | |
void | assign (const CHAR *str, uint32_t len) noexcept |
Assign operator for char* and length. More... | |
template<uint MAXLEN2> | |
void | append (const FixedString< MAXLEN2, CHAR > &other) noexcept |
Append operator for all FixedString objects. More... | |
void | append (const std::basic_string< CHAR > &str) noexcept |
Append operator for std::string. More... | |
void | append (const CHAR *str, uint32_t len) noexcept |
Append operator for char* and length. More... | |
uint32_t | length () const noexcept |
Returns the length of this string. More... | |
uint32_t | size () const noexcept |
Returns the length of this string. More... | |
uint32_t | capacity () const noexcept |
Return size of allocated storage. More... | |
uint32_t | max_size () const noexcept |
Return maximum size of string. More... | |
void | clear () noexcept |
Clear string. More... | |
bool | empty () const noexcept |
Test if string is empty. More... | |
void | zero_fill_remaining () const noexcept |
Sets zeros to unused data_ region. More... | |
const CHAR * | data () const noexcept |
Get string data. More... | |
std::basic_string< CHAR > | str () const |
Convert to a std::string object. More... | |
const CHAR * | c_str () const |
Convert to a C string. More... | |
Static Public Member Functions | |
static uint32_t | strlen (const char *str) noexcept |
static uint32_t | strlen (const wchar_t *str) noexcept |
Static Public Attributes | |
static const uint32_t | npos = -1 |
npos is a static member constant value with the greatest possible value for uint32_t. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const FixedString &v) |
|
inlinenoexcept |
|
inlineexplicitnoexcept |
Copy constructor for all FixedString objects.
Note that too-long strings are truncated.
Definition at line 72 of file fixed_string.hpp.
|
inlinenoexcept |
Copy constructor for char* and len.
Note that too-long strings are truncated.
Definition at line 75 of file fixed_string.hpp.
|
inlinenoexcept |
Copy constructor for null-terminated char*.
Note that too-long strings are truncated.
Definition at line 78 of file fixed_string.hpp.
|
inlinenoexcept |
Append operator for all FixedString objects.
Note that too-long strings are truncated.
Definition at line 138 of file fixed_string.hpp.
|
inlinenoexcept |
Append operator for std::string.
Note that too-long strings are truncated.
Definition at line 146 of file fixed_string.hpp.
|
inlinenoexcept |
Append operator for char* and length.
Note that too-long strings are truncated.
Definition at line 153 of file fixed_string.hpp.
|
inlinenoexcept |
Assign operator for all FixedString objects.
Note that too-long strings are truncated.
Definition at line 119 of file fixed_string.hpp.
Referenced by foedus::assorted::FixedString< 60 >::FixedString(), foedus::externalize::Externalizable::get_element(), foedus::FixedErrorStack::operator=(), foedus::assorted::FixedString< 60 >::operator=(), and foedus::memory::PagePoolPimpl::set_debug_pool_name().
|
inlinenoexcept |
Assign operator for std::string.
Note that too-long strings are truncated.
Definition at line 125 of file fixed_string.hpp.
|
inlinenoexcept |
Assign operator for char* and length.
Note that too-long strings are truncated.
Definition at line 131 of file fixed_string.hpp.
|
inline |
Convert to a C string.
Definition at line 189 of file fixed_string.hpp.
Referenced by foedus::proc::ProcManagerPimpl::get_proc().
|
inlinenoexcept |
Return size of allocated storage.
Actually a constexpr.
Definition at line 166 of file fixed_string.hpp.
|
inlinenoexcept |
Clear string.
Definition at line 170 of file fixed_string.hpp.
Referenced by foedus::memory::PagePoolPimpl::attach(), foedus::FixedErrorStack::from_error_stack(), foedus::thread::ThreadControlBlock::initialize(), foedus::externalize::TinyxmlGetter< assorted::FixedString< MAXLEN, CHAR > >::operator()(), and foedus::FixedErrorStack::operator=().
|
inlinenoexcept |
|
inlinenoexcept |
Test if string is empty.
Definition at line 172 of file fixed_string.hpp.
Referenced by foedus::soc::SocOptions::convert_spawn_executable_pattern(), foedus::soc::SocOptions::convert_spawn_ld_library_path_pattern(), foedus::storage::StorageManagerPimpl::create_storage(), foedus::storage::StorageManagerPimpl::create_storage_apply(), foedus::memory::PagePoolPimpl::get_debug_pool_name(), and foedus::storage::StorageManagerPimpl::initialize_read_latest_snapshot().
|
inlinenoexcept |
Returns the length of this string.
Definition at line 162 of file fixed_string.hpp.
|
inlinenoexcept |
Return maximum size of string.
Actually a constexpr.
Definition at line 168 of file fixed_string.hpp.
|
inlinenoexcept |
Definition at line 101 of file fixed_string.hpp.
|
inlinenoexcept |
Definition at line 105 of file fixed_string.hpp.
|
inlinenoexcept |
Assign operator for all FixedString objects.
Note that too-long strings are truncated.
Definition at line 87 of file fixed_string.hpp.
|
inlinenoexcept |
Definition at line 93 of file fixed_string.hpp.
Referenced by foedus::assorted::FixedString< 60 >::operator!=().
|
inlinenoexcept |
Returns the length of this string.
Definition at line 164 of file fixed_string.hpp.
|
inline |
Convert to a std::string object.
Definition at line 185 of file fixed_string.hpp.
Referenced by foedus::externalize::Externalizable::add_element(), foedus::assorted::FixedString< 60 >::append(), foedus::assorted::FixedString< 60 >::assign(), foedus::assorted::FixedString< 60 >::c_str(), foedus::log::LogOptions::convert_folder_path_pattern(), foedus::snapshot::SnapshotOptions::convert_folder_path_pattern(), foedus::proc::ProcOptions::convert_shared_library_dir_pattern(), foedus::proc::ProcOptions::convert_shared_library_path_pattern(), foedus::soc::SocOptions::convert_spawn_executable_pattern(), foedus::soc::SocOptions::convert_spawn_ld_library_path_pattern(), foedus::assorted::FixedString< 60 >::FixedString(), foedus::memory::PagePoolPimpl::get_debug_pool_name(), foedus::savepoint::SavepointManagerPimpl::initialize_once(), foedus::externalize::TinyxmlSetter< assorted::FixedString< MAXLEN, CHAR > >::operator()(), and foedus::assorted::FixedString< 60 >::strlen().
|
inlinestaticnoexcept |
Definition at line 82 of file fixed_string.hpp.
Referenced by foedus::assorted::FixedString< 60 >::FixedString().
|
inlinestaticnoexcept |
Definition at line 83 of file fixed_string.hpp.
|
inlinenoexcept |
Sets zeros to unused data_ region.
This is just to make valgrind happy.
Definition at line 174 of file fixed_string.hpp.
Referenced by foedus::storage::StorageManagerPimpl::create_storage().
|
friend |
Definition at line 200 of file fixed_string.hpp.
|
static |
npos is a static member constant value with the greatest possible value for uint32_t.
This value, when used as the value for a len (or sublen) parameter in this object, means "until the end of the string". As a return value, it is usually used to indicate no matches. This constant is defined with a value of -1, which because uint32_t is an unsigned integral type, it is the largest possible representable value for this type.
Definition at line 198 of file fixed_string.hpp.