Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::fixed_string< Storage > Class Template Reference

#include <fixed_string.hpp>

Public Member Functions

 fixed_string ()
 
 fixed_string (const fixed_string &c)
 
 fixed_string (const std::string &str)
 
 fixed_string (const char *str)
 
 operator std::string () const
 
uint32_t size () const
 
uint32_t length () const
 
fixed_stringoperator= (const fixed_string &str)
 
fixed_stringoperator= (const char *str)
 
fixed_stringoperator= (const std::string &str)
 

Public Attributes

Storage data
 

Friends

std::string operator+ (const fixed_string &a, const std::string &b)
 
std::string operator+ (const std::string &a, const fixed_string &b)
 
bool operator< (const fixed_string &a, const fixed_string &b)
 
bool operator<= (const fixed_string &a, const fixed_string &b)
 
bool operator> (const fixed_string &a, const fixed_string &b)
 
bool operator>= (const fixed_string &a, const fixed_string &b)
 
bool operator== (const fixed_string &a, const fixed_string &b)
 
bool operator!= (const fixed_string &a, const fixed_string &b)
 
std::ostream & operator<< (std::ostream &out, const fixed_string &str)
 

Detailed Description

template<typename Storage>
class fc::fixed_string< Storage >

This class is designed to offer in-place memory allocation of a string up to Length equal to sizeof(Storage).

The string will serialize the same way as std::string for variant and raw formats The string will sort according to the comparison operators defined for Storage, this enables effecient sorting.

Definition at line 26 of file raw_fwd.hpp.

Constructor & Destructor Documentation

◆ fixed_string() [1/4]

template<typename Storage >
fc::fixed_string< Storage >::fixed_string ( )
inline

Definition at line 19 of file fixed_string.hpp.

19 {
20 memset( (char*)&data, 0, sizeof(data) );
21 }
memset(pInfo->slotDescription, ' ', 64)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fixed_string() [2/4]

template<typename Storage >
fc::fixed_string< Storage >::fixed_string ( const fixed_string< Storage > & c)
inline

Definition at line 22 of file fixed_string.hpp.

22:data(c.data){}

◆ fixed_string() [3/4]

template<typename Storage >
fc::fixed_string< Storage >::fixed_string ( const std::string & str)
inline

Definition at line 24 of file fixed_string.hpp.

24 {
25 if( str.size() < sizeof(data) ) {
26 memset( (char*)&data, 0, sizeof(data) );
27 memcpy( (char*)&data, str.c_str(), str.size() );
28 } else {
29 memcpy( (char*)&data, str.c_str(), sizeof(data) );
30 }
31 }
return str
Definition CLI11.hpp:1359
memcpy((char *) pInfo->slotDescription, s, l)
Here is the call graph for this function:

◆ fixed_string() [4/4]

template<typename Storage >
fc::fixed_string< Storage >::fixed_string ( const char * str)
inline

Definition at line 32 of file fixed_string.hpp.

32 {
33 memset( (char*)&data, 0, sizeof(data) );
34 auto l = strlen(str);
35 if( l < sizeof(data) ) {
36 memset( (char*)&data, 0, sizeof(data) );
37 memcpy( (char*)&data, str, l );
38 }
39 else {
40 memcpy( (char*)&data, str, sizeof(data) );
41 }
42 }
int l
Here is the call graph for this function:

Member Function Documentation

◆ length()

template<typename Storage >
uint32_t fc::fixed_string< Storage >::length ( ) const
inline

Definition at line 54 of file fixed_string.hpp.

54{ return size(); }
uint32_t size() const
Here is the call graph for this function:

◆ operator std::string()

template<typename Storage >
fc::fixed_string< Storage >::operator std::string ( ) const
inline

Definition at line 44 of file fixed_string.hpp.

44 {
45 const char* self = (const char*)&data;
46 return std::string( self, self + size() );
47 }
@ self
the connection is to itself
Definition protocol.hpp:48
Here is the call graph for this function:

◆ operator=() [1/3]

template<typename Storage >
fixed_string & fc::fixed_string< Storage >::operator= ( const char * str)
inline

Definition at line 60 of file fixed_string.hpp.

60 {
61 return *this = fixed_string(str);
62 }
Here is the call graph for this function:

◆ operator=() [2/3]

template<typename Storage >
fixed_string & fc::fixed_string< Storage >::operator= ( const fixed_string< Storage > & str)
inline

Definition at line 56 of file fixed_string.hpp.

56 {
57 data = str.data;
58 return *this;
59 }

◆ operator=() [3/3]

template<typename Storage >
fixed_string & fc::fixed_string< Storage >::operator= ( const std::string & str)
inline

Definition at line 64 of file fixed_string.hpp.

64 {
65 if( str.size() < sizeof(data) ) {
66 memset( (char*)&data, 0, sizeof(data) );
67 memcpy( (char*)&data, str.c_str(), str.size() );
68 }
69 else {
70 memcpy( (char*)&data, str.c_str(), sizeof(data) );
71 }
72 return *this;
73 }
Here is the call graph for this function:

◆ size()

template<typename Storage >
uint32_t fc::fixed_string< Storage >::size ( ) const
inline

Definition at line 49 of file fixed_string.hpp.

49 {
50 if( *(((const char*)&data)+sizeof(data) - 1) )
51 return sizeof(data);
52 return strnlen( (const char*)&data, sizeof(data) );
53 }
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

template<typename Storage >
bool operator!= ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 97 of file fixed_string.hpp.

97 {
98 return a.data != b.data;
99 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ operator+ [1/2]

template<typename Storage >
std::string operator+ ( const fixed_string< Storage > & a,
const std::string & b )
friend

Definition at line 75 of file fixed_string.hpp.

75 {
76 return std::string(a) + b;
77 }

◆ operator+ [2/2]

template<typename Storage >
std::string operator+ ( const std::string & a,
const fixed_string< Storage > & b )
friend

Definition at line 78 of file fixed_string.hpp.

78 {
79 return a + std::string(b);
80 }

◆ operator<

template<typename Storage >
bool operator< ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 82 of file fixed_string.hpp.

82 {
83 return a.data < b.data;
84 }

◆ operator<<

template<typename Storage >
std::ostream & operator<< ( std::ostream & out,
const fixed_string< Storage > & str )
friend

Definition at line 101 of file fixed_string.hpp.

101 {
102 return out << std::string(str);
103 }

◆ operator<=

template<typename Storage >
bool operator<= ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 85 of file fixed_string.hpp.

85 {
86 return a.data <= b.data;
87 }

◆ operator==

template<typename Storage >
bool operator== ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 94 of file fixed_string.hpp.

94 {
95 return a.data == b.data;
96 }

◆ operator>

template<typename Storage >
bool operator> ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 88 of file fixed_string.hpp.

88 {
89 return a.data > b.data;
90 }

◆ operator>=

template<typename Storage >
bool operator>= ( const fixed_string< Storage > & a,
const fixed_string< Storage > & b )
friend

Definition at line 91 of file fixed_string.hpp.

91 {
92 return a.data >= b.data;
93 }

Member Data Documentation

◆ data

template<typename Storage >
Storage fc::fixed_string< Storage >::data

Definition at line 105 of file fixed_string.hpp.


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