proxygen
folly::detail::fixedstring Namespace Reference

Classes

struct  FixedStringBase_
 
struct  Helper
 
struct  ReverseIterator
 

Typedefs

using FixedStringBase = FixedStringBase_<>
 

Functions

void assertOutOfBounds ()
 
constexpr std::size_t checkOverflow (std::size_t i, std::size_t max)
 
constexpr std::size_t checkOverflowOrNpos (std::size_t i, std::size_t max)
 
void assertNotNullTerminated () noexcept
 
template<class Char , std::size_t N>
constexpr const Char(& checkNullTerminated (const Char(&a)[N]) noexcept)[N]
 
template<class Left , class Right >
constexpr ordering compare_ (const Left &left, std::size_t left_pos, std::size_t left_size, const Right &right, std::size_t right_pos, std::size_t right_size) noexcept
 
template<class Left , class Right >
constexpr bool equal_ (const Left &left, std::size_t left_size, const Right &right, std::size_t right_size) noexcept
 
template<class Char , class Left , class Right >
constexpr Char char_at_ (const Left &left, std::size_t left_count, const Right &right, std::size_t right_count, std::size_t i) noexcept
 
template<class Char , class Left , class Right >
constexpr Char char_at_ (const Left &left, std::size_t left_size, std::size_t left_pos, std::size_t left_count, const Right &right, std::size_t right_pos, std::size_t right_count, std::size_t i) noexcept
 
template<class Left , class Right >
constexpr bool find_at_ (const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Char , class Right >
constexpr bool find_one_of_at_ (Char ch, const Right &right, std::size_t pos) noexcept
 
template<class Left , class Right >
constexpr std::size_t find_ (const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Left , class Right >
constexpr std::size_t rfind_ (const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Left , class Right >
constexpr std::size_t find_first_of_ (const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Left , class Right >
constexpr std::size_t find_first_not_of_ (const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Left , class Right >
constexpr std::size_t find_last_of_ (const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class Left , class Right >
constexpr std::size_t find_last_not_of_ (const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
 
template<class T >
FOLLY_CPP14_CONSTEXPR void constexpr_swap (T &a, T &b) noexcept(noexcept(a=T(std::move(a))))
 

Typedef Documentation

Definition at line 60 of file FixedString.h.

Function Documentation

void folly::detail::fixedstring::assertNotNullTerminated ( )
inlinenoexcept

Definition at line 83 of file FixedString.h.

Referenced by checkNullTerminated().

83  {
84  assert(!"Non-null terminated string used to initialize a BasicFixedString");
85  std::terminate(); // Fail hard, fail fast.
86 }
void folly::detail::fixedstring::assertOutOfBounds ( )
inline

Definition at line 66 of file FixedString.h.

Referenced by checkOverflow(), and checkOverflowOrNpos().

66  {
67  assert(!"Array index out of bounds in BasicFixedString");
68  throw_exception<std::out_of_range>(
69  "Array index out of bounds in BasicFixedString");
70 }
template<class Char , class Left , class Right >
constexpr Char folly::detail::fixedstring::char_at_ ( const Left &  left,
std::size_t  left_count,
const Right &  right,
std::size_t  right_count,
std::size_t  i 
)
noexcept

Definition at line 145 of file FixedString.h.

References testing::gmock_generated_actions_test::Char(), and i.

150  {
151  return i < left_count
152  ? left[i]
153  : i < (left_count + right_count) ? right[i - left_count] : Char(0);
154 }
template<class Char , class Left , class Right >
constexpr Char folly::detail::fixedstring::char_at_ ( const Left &  left,
std::size_t  left_size,
std::size_t  left_pos,
std::size_t  left_count,
const Right &  right,
std::size_t  right_pos,
std::size_t  right_count,
std::size_t  i 
)
noexcept

Definition at line 157 of file FixedString.h.

References testing::gmock_generated_actions_test::Char(), and i.

165  {
166  return i < left_pos
167  ? left[i]
168  : (i < right_count + left_pos ? right[i - left_pos + right_pos]
169  : (i < left_size - left_count + right_count
170  ? left[i - right_count + left_count]
171  : Char(0)));
172 }
template<class Char , std::size_t N>
constexpr const Char(& folly::detail::fixedstring::checkNullTerminated ( const Char(&)  a[N]) )[N]

Definition at line 92 of file FixedString.h.

References a, assertNotNullTerminated(), testing::gmock_generated_actions_test::Char(), and folly::detail::constexpr_strlen_internal().

Referenced by folly::BasicFixedString< Char, N >::assign(), folly::BasicFixedString< Char, N >::BasicFixedString(), folly::BasicFixedString< Char, N >::creplace(), and folly::BasicFixedString< Char, N >::operator=().

92  {
93  // Strange decltype(a)(a) used to make MSVC happy.
94  return a[N - 1u] == Char(0)
95 #ifndef NDEBUG
96  // In Debug mode, guard against embedded nulls:
98 #endif
99  ? decltype(a)(a)
100  : (assertNotNullTerminated(), decltype(a)(a));
101 }
constexpr size_t constexpr_strlen_internal(const Char *s, size_t len)
Definition: Constexpr.h:30
char a
void assertNotNullTerminated() noexcept
Definition: FixedString.h:83
constexpr std::size_t folly::detail::fixedstring::checkOverflow ( std::size_t  i,
std::size_t  max 
)
template<class Left , class Right >
constexpr ordering folly::detail::fixedstring::compare_ ( const Left &  left,
std::size_t  left_pos,
std::size_t  left_size,
const Right &  right,
std::size_t  right_pos,
std::size_t  right_size 
)
noexcept

Definition at line 111 of file FixedString.h.

References folly::eq, folly::gt, and folly::lt.

Referenced by folly::BasicFixedString< Char, N >::compare(), equal_(), and folly::operator<().

117  {
118  return left_pos == left_size
119  ? (right_pos == right_size ? ordering::eq : ordering::lt)
120  : (right_pos == right_size ? ordering::gt
121  : (left[left_pos] < right[right_pos]
122  ? ordering::lt
123  : (left[left_pos] > right[right_pos]
124  ? ordering::gt
126  left,
127  left_pos + 1u,
128  left_size,
129  right,
130  right_pos + 1u,
131  right_size))));
132 }
constexpr ordering compare_(const Left &left, std::size_t left_pos, std::size_t left_size, const Right &right, std::size_t right_pos, std::size_t right_size) noexcept
Definition: FixedString.h:111
template<class T >
FOLLY_CPP14_CONSTEXPR void folly::detail::fixedstring::constexpr_swap ( T a,
T b 
)
noexcept

Definition at line 310 of file FixedString.h.

References a, b, folly::gen::move, and folly::T.

Referenced by folly::BasicFixedString< Char, N >::swap().

311  {
312  T tmp((std::move(a)));
313  a = std::move(b);
314  b = std::move(tmp);
315 }
#define T(v)
Definition: http_parser.c:233
char b
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
char a
template<class Left , class Right >
constexpr bool folly::detail::fixedstring::equal_ ( const Left &  left,
std::size_t  left_size,
const Right &  right,
std::size_t  right_size 
)
noexcept

Definition at line 135 of file FixedString.h.

References compare_(), and folly::eq.

Referenced by folly::f14::GenericEqual< T >::operator()(), and folly::operator==().

139  {
140  return left_size == right_size &&
141  ordering::eq == compare_(left, 0u, left_size, right, 0u, right_size);
142 }
constexpr ordering compare_(const Left &left, std::size_t left_pos, std::size_t left_size, const Right &right, std::size_t right_pos, std::size_t right_size) noexcept
Definition: FixedString.h:111
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::find_ ( const Left &  left,
std::size_t  left_size,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 193 of file FixedString.h.

References count, find_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::find().

198  {
199  return find_at_(left, right, pos, count) ? pos
200  : left_size <= pos + count
201  ? FixedStringBase::npos
202  : find_(left, left_size, right, pos + 1u, count);
203 }
constexpr bool find_at_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:175
constexpr std::size_t find_(const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:193
int * count
template<class Left , class Right >
constexpr bool folly::detail::fixedstring::find_at_ ( const Left &  left,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 175 of file FixedString.h.

References count.

Referenced by find_(), and rfind_().

179  {
180  return 0u == count ||
181  (left[pos + count - 1u] == right[count - 1u] &&
182  find_at_(left, right, pos, count - 1u));
183 }
constexpr bool find_at_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:175
int * count
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::find_first_not_of_ ( const Left &  left,
std::size_t  left_size,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 231 of file FixedString.h.

References count, find_one_of_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::find_first_not_of().

236  {
237  return !find_one_of_at_(left[pos], right, count) ? pos
238  : left_size <= pos + 1u
239  ? FixedStringBase::npos
240  : find_first_not_of_(left, left_size, right, pos + 1u, count);
241 }
constexpr bool find_one_of_at_(Char ch, const Right &right, std::size_t pos) noexcept
Definition: FixedString.h:187
int * count
constexpr std::size_t find_first_not_of_(const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:231
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::find_first_of_ ( const Left &  left,
std::size_t  left_size,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 218 of file FixedString.h.

References count, find_one_of_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::find_first_of().

223  {
224  return find_one_of_at_(left[pos], right, count) ? pos
225  : left_size <= pos + 1u
226  ? FixedStringBase::npos
227  : find_first_of_(left, left_size, right, pos + 1u, count);
228 }
constexpr bool find_one_of_at_(Char ch, const Right &right, std::size_t pos) noexcept
Definition: FixedString.h:187
constexpr std::size_t find_first_of_(const Left &left, std::size_t left_size, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:218
int * count
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::find_last_not_of_ ( const Left &  left,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 256 of file FixedString.h.

References count, find_one_of_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::find_last_not_of().

260  {
261  return !find_one_of_at_(left[pos], right, count)
262  ? pos
263  : 0u == pos ? FixedStringBase::npos
264  : find_last_not_of_(left, right, pos - 1u, count);
265 }
constexpr bool find_one_of_at_(Char ch, const Right &right, std::size_t pos) noexcept
Definition: FixedString.h:187
constexpr std::size_t find_last_not_of_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:256
int * count
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::find_last_of_ ( const Left &  left,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 244 of file FixedString.h.

References count, find_one_of_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::find_last_of().

248  {
249  return find_one_of_at_(left[pos], right, count)
250  ? pos
251  : 0u == pos ? FixedStringBase::npos
252  : find_last_of_(left, right, pos - 1u, count);
253 }
constexpr bool find_one_of_at_(Char ch, const Right &right, std::size_t pos) noexcept
Definition: FixedString.h:187
constexpr std::size_t find_last_of_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:244
int * count
template<class Char , class Right >
constexpr bool folly::detail::fixedstring::find_one_of_at_ ( Char  ch,
const Right &  right,
std::size_t  pos 
)
noexcept

Definition at line 187 of file FixedString.h.

References ch.

Referenced by find_first_not_of_(), find_first_of_(), find_last_not_of_(), and find_last_of_().

187  {
188  return 0u != pos &&
189  (ch == right[pos - 1u] || find_one_of_at_(ch, right, pos - 1u));
190 }
auto ch
constexpr bool find_one_of_at_(Char ch, const Right &right, std::size_t pos) noexcept
Definition: FixedString.h:187
template<class Left , class Right >
constexpr std::size_t folly::detail::fixedstring::rfind_ ( const Left &  left,
const Right &  right,
std::size_t  pos,
std::size_t  count 
)
noexcept

Definition at line 206 of file FixedString.h.

References count, find_at_(), and folly::detail::fixedstring::FixedStringBase_< class >::npos.

Referenced by folly::BasicFixedString< Char, N >::rfind().

210  {
211  return find_at_(left, right, pos, count)
212  ? pos
213  : 0u == pos ? FixedStringBase::npos
214  : rfind_(left, right, pos - 1u, count);
215 }
constexpr bool find_at_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:175
constexpr std::size_t rfind_(const Left &left, const Right &right, std::size_t pos, std::size_t count) noexcept
Definition: FixedString.h:206
int * count