libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal::StringViewBase< CRTP > Class Template Reference
Inheritance diagram for gimbal::StringViewBase< CRTP >:
gimbal::tags::StringBase

Public Types

using StringViewType = StringViewBase< CRTP >
 
using Derived = CRTP
 
using Iterable = RandomAccessIterable< StringViewType, size_t, char >
 
using iterator = typename Iterable::iterator
 
using const_iterator = typename Iterable::const_iterator
 

Public Member Functions

 operator const GblStringBuffer * () const
 
const char & getElement_ (size_t index) const
 
char & getElement_ (size_t index)
 
void setElement_ (size_t index, char value)
 
size_t getElementCount_ (void) const
 
Size getStackBytes (void) const
 
constexpr Size getLength (void) const
 
constexpr Size getCapacity (void) const
 
ContextgetContext (void) const
 
constexpr bool isEmpty (void) const
 
constexpr bool isStack (void) const
 
constexpr bool isHeap (void) const
 
const char * getCString (void) const
 
char * getCString (void)
 
std::string toStdString (void) const
 
constexpr std::string_view toStringView (void) const
 

Protected Member Functions

decltype(auto) str_ (void) const
 
decltype(auto) str_ (void)
 

Friends

constexpr bool operator== (const Derived &lhs, const char *pRhs) noexcept
 
constexpr decltype(auto) operator<=> (const Derived &lhs, const char *pRhs) noexcept
 
constexpr bool operator== (const Derived &lhs, const std::string &rhs) noexcept
 
constexpr decltype(auto) operator<=> (const Derived &lhs, const std::string &rhs) noexcept
 
constexpr bool operator== (const Derived &lhs, std::string_view rhs) noexcept
 
constexpr decltype(auto) operator<=> (const Derived &lhs, std::string_view rhs) noexcept
 
constexpr bool operator== (const Derived &lhs, const string_base auto &rhs)
 
constexpr decltype(auto) operator<=> (const Derived &lhs, const string_base auto &rhs)
 
std::ostream & operator<< (std::ostream &output, const Derived &s)
 

Detailed Description

template<typename CRTP>
class gimbal::StringViewBase< CRTP >

Definition at line 31 of file gimbal_string.hpp.

Member Typedef Documentation

◆ StringViewType

template<typename CRTP >
using gimbal::StringViewBase< CRTP >::StringViewType = StringViewBase<CRTP>

Definition at line 37 of file gimbal_string.hpp.

◆ Derived

template<typename CRTP >
using gimbal::StringViewBase< CRTP >::Derived = CRTP

Definition at line 38 of file gimbal_string.hpp.

◆ Iterable

template<typename CRTP >
using gimbal::StringViewBase< CRTP >::Iterable = RandomAccessIterable<StringViewType, size_t, char>

Definition at line 39 of file gimbal_string.hpp.

◆ iterator

template<typename CRTP >
using gimbal::StringViewBase< CRTP >::iterator = typename Iterable::iterator

Definition at line 40 of file gimbal_string.hpp.

◆ const_iterator

template<typename CRTP >
using gimbal::StringViewBase< CRTP >::const_iterator = typename Iterable::const_iterator

Definition at line 41 of file gimbal_string.hpp.

Member Function Documentation

◆ str_() [1/2]

template<typename CRTP >
decltype(auto) gimbal::StringViewBase< CRTP >::str_ ( void  ) const
inlineprotected

Definition at line 43 of file gimbal_string.hpp.

43 {
44 return static_cast<const CRTP*>(this)->getString_();
45 }

◆ str_() [2/2]

template<typename CRTP >
decltype(auto) gimbal::StringViewBase< CRTP >::str_ ( void  )
inlineprotected

Definition at line 47 of file gimbal_string.hpp.

47 {
48 return static_cast<CRTP*>(this)->getString_();
49 }

◆ operator const GblStringBuffer *()

template<typename CRTP >
gimbal::StringViewBase< CRTP >::operator const GblStringBuffer * ( ) const
inline

Definition at line 53 of file gimbal_string.hpp.

53{ return str_(); }

◆ getElement_() [1/2]

template<typename CRTP >
const char & gimbal::StringViewBase< CRTP >::getElement_ ( size_t  index) const
inline

Definition at line 56 of file gimbal_string.hpp.

56 {
57 return getCString()[index];
58 }

◆ getElement_() [2/2]

template<typename CRTP >
char & gimbal::StringViewBase< CRTP >::getElement_ ( size_t  index)
inline

Definition at line 60 of file gimbal_string.hpp.

60 {
61 return getCString()[index];
62 }

◆ setElement_()

template<typename CRTP >
void gimbal::StringViewBase< CRTP >::setElement_ ( size_t  index,
char  value 
)
inline

Definition at line 64 of file gimbal_string.hpp.

64 {
65 const_cast<char*>(getCString())[index] = value;
66 }

◆ getElementCount_()

template<typename CRTP >
size_t gimbal::StringViewBase< CRTP >::getElementCount_ ( void  ) const
inline

Definition at line 68 of file gimbal_string.hpp.

68 {
69 return getLength();
70 }

◆ getStackBytes()

template<typename CRTP >
Size gimbal::StringViewBase< CRTP >::getStackBytes ( void  ) const
inline

Definition at line 74 of file gimbal_string.hpp.

74 {
75 Size size = GblStringBuffer_stackBytes(str_());
76 return size;
77 }

◆ getLength()

template<typename CRTP >
constexpr Size gimbal::StringViewBase< CRTP >::getLength ( void  ) const
inlineconstexpr

Definition at line 79 of file gimbal_string.hpp.

79 {
80 return GblStringBuffer_length(str_());
81 }

◆ getCapacity()

template<typename CRTP >
constexpr Size gimbal::StringViewBase< CRTP >::getCapacity ( void  ) const
inlineconstexpr

Definition at line 83 of file gimbal_string.hpp.

83 {
84 return GblStringBuffer_capacity(str_());
85 }

◆ getContext()

template<typename CRTP >
Context * gimbal::StringViewBase< CRTP >::getContext ( void  ) const
inline

Definition at line 87 of file gimbal_string.hpp.

87 {
88 GblContext* pCtx = GblStringBuffer_context(str_());
89 return pCtx == nullptr? nullptr : Context::fromGblObj(pCtx);
90 }
Top-level context object.

◆ isEmpty()

template<typename CRTP >
constexpr bool gimbal::StringViewBase< CRTP >::isEmpty ( void  ) const
inlineconstexpr

Definition at line 92 of file gimbal_string.hpp.

92 {
93 GblBool empty = GblStringBuffer_empty(str_());
94 return empty;
95 }
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)

◆ isStack()

template<typename CRTP >
constexpr bool gimbal::StringViewBase< CRTP >::isStack ( void  ) const
inlineconstexpr

Definition at line 97 of file gimbal_string.hpp.

97 {
98 GblBool stack = GblStringBuffer_stack(str_());
99 return stack;
100 }

◆ isHeap()

template<typename CRTP >
constexpr bool gimbal::StringViewBase< CRTP >::isHeap ( void  ) const
inlineconstexpr

Definition at line 104 of file gimbal_string.hpp.

104 {
105 return !isStack();
106 }

◆ getCString() [1/2]

template<typename CRTP >
const char * gimbal::StringViewBase< CRTP >::getCString ( void  ) const
inline

Definition at line 108 of file gimbal_string.hpp.

108 {
109 const char* pCStr = GblStringBuffer_cString(str_());
110 return pCStr;
111 }

◆ getCString() [2/2]

template<typename CRTP >
char * gimbal::StringViewBase< CRTP >::getCString ( void  )
inline

Definition at line 113 of file gimbal_string.hpp.

113 {
114 const char* pStr = GblStringBuffer_cString(str_());
115 return const_cast<char*>(pStr);
116 }

◆ toStdString()

template<typename CRTP >
std::string gimbal::StringViewBase< CRTP >::toStdString ( void  ) const
inline

Definition at line 118 of file gimbal_string.hpp.

118 {
119 return std::string(getCString());
120 }

◆ toStringView()

template<typename CRTP >
constexpr std::string_view gimbal::StringViewBase< CRTP >::toStringView ( void  ) const
inlineconstexpr

Definition at line 122 of file gimbal_string.hpp.

122 {
123 return getLength()?
124 std::string_view(getCString(), getLength()) : std::string_view();
125 }

Friends And Related Symbol Documentation

◆ operator== [1/4]

template<typename CRTP >
constexpr bool operator== ( const Derived &  lhs,
const char *  pRhs 
)
friend

Definition at line 126 of file gimbal_string.hpp.

126 {
127 return (lhs.toStringView() == std::string_view(pRhs));
128 }

◆ operator<=> [1/4]

template<typename CRTP >
constexpr decltype(auto) operator<=> ( const Derived &  lhs,
const char *  pRhs 
)
friend

Definition at line 129 of file gimbal_string.hpp.

129 {
130 return (lhs.toStringView() <=> std::string_view(pRhs));
131 }

◆ operator== [2/4]

template<typename CRTP >
constexpr bool operator== ( const Derived &  lhs,
const std::string &  rhs 
)
friend

Definition at line 132 of file gimbal_string.hpp.

132 {
133 return (lhs.toStdString() == rhs);
134 }

◆ operator<=> [2/4]

template<typename CRTP >
constexpr decltype(auto) operator<=> ( const Derived &  lhs,
const std::string &  rhs 
)
friend

Definition at line 135 of file gimbal_string.hpp.

135 {
136 return (lhs.toStdString() <=> rhs);
137 }

◆ operator== [3/4]

template<typename CRTP >
constexpr bool operator== ( const Derived &  lhs,
std::string_view  rhs 
)
friend

Definition at line 146 of file gimbal_string.hpp.

146 {
147 return (lhs.toStringView() == rhs);
148 }

◆ operator<=> [3/4]

template<typename CRTP >
constexpr decltype(auto) operator<=> ( const Derived &  lhs,
std::string_view  rhs 
)
friend

Definition at line 149 of file gimbal_string.hpp.

149 {
150 return (lhs.toStringView() <=> rhs);
151 }

◆ operator== [4/4]

template<typename CRTP >
constexpr bool operator== ( const Derived &  lhs,
const string_base auto &  rhs 
)
friend

Definition at line 152 of file gimbal_string.hpp.

152 {
153 gimbal::Int result = GblStringBuffer_compare(&lhs, &rhs);
154 return result == 0;
155 }

◆ operator<=> [4/4]

template<typename CRTP >
constexpr decltype(auto) operator<=> ( const Derived &  lhs,
const string_base auto &  rhs 
)
friend

Definition at line 156 of file gimbal_string.hpp.

156 {
157 return (lhs <=> rhs);
158 }

◆ operator<<

template<typename CRTP >
std::ostream & operator<< ( std::ostream &  output,
const Derived &  s 
)
friend

Definition at line 159 of file gimbal_string.hpp.

159 {
160 output << s.getCString();
161 if(output.fail()) Exception::checkThrow(Result::ErrorFileWrite);
162 return output;
163 }

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