8#ifndef INCLUDED_BDLJSN_TOKENIZER
9#define INCLUDED_BDLJSN_TOKENIZER
208#include <bdlscm_version.h>
217#include <bsl_streambuf.h>
218#include <bsl_string.h>
219#include <bsl_string_view.h>
220#include <bsl_vector.h>
252#ifndef BDE_OMIT_INTERNAL_DEPRECATED
286 k_BUFSIZE = 1024 * 8,
287 k_MAX_STRING_SIZE = k_BUFSIZE - 1,
289 k_CONTEXTSTACKBUFSIZE = 256
307 bsl::streambuf *d_streambuf_p;
309 bsl::size_t d_cursor;
311 bsl::size_t d_valueBegin;
313 bsl::size_t d_valueEnd;
315 bsl::size_t d_valueIter;
336 bool d_allowConsecutiveSeparators;
340 bool d_allowFormFeedAsWhitespace;
345 bool d_allowHeterogenousArrays;
349 bool d_allowNonUtf8StringLiterals;
352 bool d_allowStandAloneValues;
356 bool d_allowTrailingTopLevelComma;
359 bool d_allowUnescapedControlCharacters;
371 int expandBufferForLargeValue();
377 int extractStringValue();
388 int moveValueCharsToStartAndReloadBuffer();
392 ContextType popContext();
395 void pushContext(ContextType context);
401 int reloadStringBuffer();
406 int skipNonWhitespaceOrTillToken();
411 int skipWhitespace();
418 ContextType context()
const;
422 Tokenizer(
const Tokenizer&);
423 Tokenizer& operator=(
const Tokenizer&);
476 void reset(bsl::streambuf *streambuf);
706Tokenizer::ContextType Tokenizer::popContext()
708 ContextType ret = e_NO_CONTEXT;
710 if (!d_contextStack.
empty()) {
711 ret =
static_cast<ContextType
>(d_contextStack.
back());
719void Tokenizer::pushContext(ContextType context)
721 d_contextStack.
push_back(
static_cast<char>(context));
726Tokenizer::ContextType Tokenizer::context()
const
728 return d_contextStack.
empty()
730 :
static_cast<ContextType
>(d_contextStack.
back());
736: d_allocator(d_buffer.buffer(), k_BUFSIZE, basicAllocator)
737, d_stackAllocator(d_stackBuffer.buffer(),
738 k_CONTEXTSTACKBUFSIZE,
740, d_stringBuffer(&d_allocator)
747, d_tokenType(e_BEGIN)
748, d_contextStack(200, &d_stackAllocator)
751, d_allowConsecutiveSeparators(true)
752, d_allowFormFeedAsWhitespace(true)
753, d_allowHeterogenousArrays(true)
754, d_allowNonUtf8StringLiterals(true)
755, d_allowStandAloneValues(true)
756, d_allowTrailingTopLevelComma(true)
757, d_allowUnescapedControlCharacters(true)
758, d_conformanceMode(e_RELAXED)
760 d_stringBuffer.
reserve(k_MAX_STRING_SIZE);
761 d_contextStack.
clear();
762 pushContext(e_NO_CONTEXT);
774 d_streambuf_p = streambuf;
775 d_stringBuffer.
clear();
785 d_contextStack.
clear();
786 pushContext(e_NO_CONTEXT);
794 d_allowConsecutiveSeparators =
value;
803 d_allowHeterogenousArrays =
value;
812 d_allowFormFeedAsWhitespace =
value;
821 d_allowNonUtf8StringLiterals =
value;
830 d_allowStandAloneValues =
value;
839 d_allowTrailingTopLevelComma =
value;
848 d_allowUnescapedControlCharacters =
value;
855 d_conformanceMode = mode;
861 d_allowConsecutiveSeparators =
false;
862 d_allowFormFeedAsWhitespace =
false;
863 d_allowHeterogenousArrays =
true;
864 d_allowNonUtf8StringLiterals =
false;
865 d_allowStandAloneValues =
true;
866 d_allowTrailingTopLevelComma =
false;
867 d_allowUnescapedControlCharacters =
false;
880 return d_allowConsecutiveSeparators;
886 return d_allowFormFeedAsWhitespace;
892 return d_allowHeterogenousArrays;
898 return d_allowNonUtf8StringLiterals;
904 return d_allowStandAloneValues;
910 return d_allowTrailingTopLevelComma;
916 return d_allowUnescapedControlCharacters;
922 return d_conformanceMode;
928 return d_readOffset - d_stringBuffer.
size() + d_cursor;
Definition bdljsn_tokenizer.h:234
bool allowConsecutiveSeparators() const
Definition bdljsn_tokenizer.h:878
int resetStreamBufGetPointer()
bool allowFormFeedAsWhitespace() const
Definition bdljsn_tokenizer.h:884
bsls::Types::Uint64 Uint64
Definition bdljsn_tokenizer.h:239
~Tokenizer()
Destroy this object.
Definition bdljsn_tokenizer.h:766
TokenType tokenType() const
Return the token type of the current token.
Definition bdljsn_tokenizer.h:944
Tokenizer & setAllowConsecutiveSeparators(bool value)
Definition bdljsn_tokenizer.h:790
bool allowNonUtf8StringLiterals() const
Definition bdljsn_tokenizer.h:896
bsls::Types::Uint64 readOffset() const
Definition bdljsn_tokenizer.h:932
Tokenizer & setAllowHeterogenousArrays(bool value)
Definition bdljsn_tokenizer.h:799
Tokenizer & setAllowStandAloneValues(bool value)
Definition bdljsn_tokenizer.h:826
bsls::Types::IntPtr IntPtr
Definition bdljsn_tokenizer.h:238
Tokenizer & setAllowUnescapedControlCharacters(bool value)
Definition bdljsn_tokenizer.h:844
bool allowStandAloneValues() const
Definition bdljsn_tokenizer.h:902
Tokenizer & setAllowTrailingTopLevelComma(bool value)
Definition bdljsn_tokenizer.h:835
int readStatus() const
Definition bdljsn_tokenizer.h:938
ConformanceMode
Definition bdljsn_tokenizer.h:266
@ e_RELAXED
Definition bdljsn_tokenizer.h:267
@ e_STRICT_20240119
Definition bdljsn_tokenizer.h:268
Tokenizer & setAllowFormFeedAsWhitespace(bool value)
Definition bdljsn_tokenizer.h:808
ConformanceMode conformanceMode() const
Return the conformanceMode of this tokenizer.
Definition bdljsn_tokenizer.h:920
void reset(bsl::streambuf *streambuf)
Definition bdljsn_tokenizer.h:772
Tokenizer & setConformanceMode(ConformanceMode mode)
Definition bdljsn_tokenizer.h:853
bool allowUnescapedControlCharacters() const
Definition bdljsn_tokenizer.h:914
bool allowHeterogenousArrays() const
Definition bdljsn_tokenizer.h:890
Tokenizer & setAllowNonUtf8StringLiterals(bool value)
Definition bdljsn_tokenizer.h:817
bsls::Types::Uint64 currentPosition() const
Definition bdljsn_tokenizer.h:926
@ k_EOF
Definition bdljsn_tokenizer.h:264
TokenType
Definition bdljsn_tokenizer.h:241
@ e_ELEMENT_NAME
Definition bdljsn_tokenizer.h:245
@ e_END_OBJECT
Definition bdljsn_tokenizer.h:247
@ BAEJSN_END_ARRAY
Definition bdljsn_tokenizer.h:258
@ e_BEGIN
Definition bdljsn_tokenizer.h:244
@ BAEJSN_ELEMENT_NAME
Definition bdljsn_tokenizer.h:254
@ e_END_ARRAY
Definition bdljsn_tokenizer.h:249
@ e_ELEMENT_VALUE
Definition bdljsn_tokenizer.h:250
@ BAEJSN_START_ARRAY
Definition bdljsn_tokenizer.h:257
@ BAEJSN_END_OBJECT
Definition bdljsn_tokenizer.h:256
@ BAEJSN_START_OBJECT
Definition bdljsn_tokenizer.h:255
@ e_ERROR
Definition bdljsn_tokenizer.h:251
@ e_START_ARRAY
Definition bdljsn_tokenizer.h:248
@ BAEJSN_ERROR
Definition bdljsn_tokenizer.h:260
@ e_START_OBJECT
Definition bdljsn_tokenizer.h:246
@ BAEJSN_ELEMENT_VALUE
Definition bdljsn_tokenizer.h:259
int value(bsl::string_view *data) const
bool allowTrailingTopLevelComma() const
Definition bdljsn_tokenizer.h:908
Definition bdlma_bufferedsequentialallocator.h:266
Definition bslstl_stringview.h:471
Definition bslstl_string.h:1252
size_type size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:7292
void reserve(size_type newCapacity)
Definition bslstl_string.h:6020
void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6043
reference back()
Definition bslstl_vector.h:2932
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this vector has size 0, and false otherwise.
Definition bslstl_vector.h:3034
Definition bslstl_vector.h:1120
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:4343
void swap(vector &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:1938
void pop_back()
Definition bslstl_vector.h:4375
Definition bslma_allocator.h:545
Definition bsls_alignedbuffer.h:262
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:2045
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdljsn_error.h:142
unsigned long long Uint64
Definition bsls_types.h:139
std::ptrdiff_t IntPtr
Definition bsls_types.h:132