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();
387 int moveValueCharsToStartAndReloadBuffer();
391 ContextType popContext();
394 void pushContext(ContextType context);
400 int reloadStringBuffer();
405 int skipNonWhitespaceOrTillToken();
410 int skipWhitespace();
417 ContextType context()
const;
421 Tokenizer(
const Tokenizer&);
422 Tokenizer& operator=(
const Tokenizer&);
472 void reset(bsl::streambuf *streambuf);
687Tokenizer::ContextType Tokenizer::popContext()
689 ContextType ret = e_NO_CONTEXT;
691 if (!d_contextStack.
empty()) {
692 ret =
static_cast<ContextType
>(d_contextStack.
back());
700void Tokenizer::pushContext(ContextType context)
702 d_contextStack.
push_back(
static_cast<char>(context));
707Tokenizer::ContextType Tokenizer::context()
const
709 return d_contextStack.
empty()
711 :
static_cast<ContextType
>(d_contextStack.
back());
717: d_allocator(d_buffer.buffer(), k_BUFSIZE, basicAllocator)
718, d_stackAllocator(d_stackBuffer.buffer(),
719 k_CONTEXTSTACKBUFSIZE,
721, d_stringBuffer(&d_allocator)
728, d_tokenType(e_BEGIN)
729, d_contextStack(200, &d_stackAllocator)
732, d_allowConsecutiveSeparators(true)
733, d_allowFormFeedAsWhitespace(true)
734, d_allowHeterogenousArrays(true)
735, d_allowNonUtf8StringLiterals(true)
736, d_allowStandAloneValues(true)
737, d_allowTrailingTopLevelComma(true)
738, d_allowUnescapedControlCharacters(true)
739, d_conformanceMode(e_RELAXED)
741 d_stringBuffer.
reserve(k_MAX_STRING_SIZE);
742 d_contextStack.
clear();
743 pushContext(e_NO_CONTEXT);
755 d_streambuf_p = streambuf;
756 d_stringBuffer.
clear();
766 d_contextStack.
clear();
767 pushContext(e_NO_CONTEXT);
775 d_allowConsecutiveSeparators =
value;
784 d_allowHeterogenousArrays =
value;
793 d_allowFormFeedAsWhitespace =
value;
802 d_allowNonUtf8StringLiterals =
value;
811 d_allowStandAloneValues =
value;
820 d_allowTrailingTopLevelComma =
value;
829 d_allowUnescapedControlCharacters =
value;
836 d_conformanceMode = mode;
842 d_allowConsecutiveSeparators =
false;
843 d_allowFormFeedAsWhitespace =
false;
844 d_allowHeterogenousArrays =
true;
845 d_allowNonUtf8StringLiterals =
false;
846 d_allowStandAloneValues =
true;
847 d_allowTrailingTopLevelComma =
false;
848 d_allowUnescapedControlCharacters =
false;
861 return d_allowConsecutiveSeparators;
867 return d_allowFormFeedAsWhitespace;
873 return d_allowHeterogenousArrays;
879 return d_allowNonUtf8StringLiterals;
885 return d_allowStandAloneValues;
891 return d_allowTrailingTopLevelComma;
897 return d_allowUnescapedControlCharacters;
903 return d_conformanceMode;
909 return d_readOffset - d_stringBuffer.
size() + d_cursor;
Definition bdljsn_tokenizer.h:234
bool allowConsecutiveSeparators() const
Definition bdljsn_tokenizer.h:859
int resetStreamBufGetPointer()
bool allowFormFeedAsWhitespace() const
Definition bdljsn_tokenizer.h:865
bsls::Types::Uint64 Uint64
Definition bdljsn_tokenizer.h:239
@ k_EOF
Definition bdljsn_tokenizer.h:264
~Tokenizer()
Destroy this object.
Definition bdljsn_tokenizer.h:747
TokenType tokenType() const
Return the token type of the current token.
Definition bdljsn_tokenizer.h:925
Tokenizer & setAllowConsecutiveSeparators(bool value)
Definition bdljsn_tokenizer.h:771
bool allowNonUtf8StringLiterals() const
Definition bdljsn_tokenizer.h:877
bsls::Types::Uint64 readOffset() const
Definition bdljsn_tokenizer.h:913
Tokenizer & setAllowHeterogenousArrays(bool value)
Definition bdljsn_tokenizer.h:780
Tokenizer & setAllowStandAloneValues(bool value)
Definition bdljsn_tokenizer.h:807
bsls::Types::IntPtr IntPtr
Definition bdljsn_tokenizer.h:238
Tokenizer & setAllowUnescapedControlCharacters(bool value)
Definition bdljsn_tokenizer.h:825
bool allowStandAloneValues() const
Definition bdljsn_tokenizer.h:883
Tokenizer & setAllowTrailingTopLevelComma(bool value)
Definition bdljsn_tokenizer.h:816
int readStatus() const
Definition bdljsn_tokenizer.h:919
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:789
ConformanceMode conformanceMode() const
Return the conformanceMode of this tokenizer.
Definition bdljsn_tokenizer.h:901
void reset(bsl::streambuf *streambuf)
Definition bdljsn_tokenizer.h:753
Tokenizer & setConformanceMode(ConformanceMode mode)
Definition bdljsn_tokenizer.h:834
bool allowUnescapedControlCharacters() const
Definition bdljsn_tokenizer.h:895
bool allowHeterogenousArrays() const
Definition bdljsn_tokenizer.h:871
Tokenizer & setAllowNonUtf8StringLiterals(bool value)
Definition bdljsn_tokenizer.h:798
bsls::Types::Uint64 currentPosition() const
Definition bdljsn_tokenizer.h:907
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:889
Definition bdlma_bufferedsequentialallocator.h:265
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
void reserve(size_type newCapacity=0)
Definition bslstl_string.h:5407
size_type size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6592
void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:5430
reference back()
Definition bslstl_vector.h:2577
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this vector has size 0, and false otherwise.
Definition bslstl_vector.h:2679
Definition bslstl_vector.h:1025
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:3760
void swap(vector &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:1712
void pop_back()
Definition bslstl_vector.h:3792
Definition bslma_allocator.h:457
Definition bsls_alignedbuffer.h:261
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdljsn_error.h:143
unsigned long long Uint64
Definition bsls_types.h:137
std::ptrdiff_t IntPtr
Definition bsls_types.h:130