123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- #ifndef BOOST_JSON_VALUE_STACK_HPP
- #define BOOST_JSON_VALUE_STACK_HPP
- #include <boost/json/detail/config.hpp>
- #include <boost/json/error.hpp>
- #include <boost/json/storage_ptr.hpp>
- #include <boost/json/value.hpp>
- #include <stddef.h>
- namespace boost {
- namespace json {
- class value_stack
- {
- class stack
- {
- enum
- {
- min_size_ = 16
- };
- storage_ptr sp_;
- void* temp_;
- value* begin_;
- value* top_;
- value* end_;
-
- std::size_t chars_ = 0;
- bool run_dtors_ = true;
- public:
- inline ~stack();
- inline stack(
- storage_ptr sp,
- void* temp, std::size_t size) noexcept;
- inline void run_dtors(bool b) noexcept;
- inline std::size_t size() const noexcept;
- inline bool has_chars();
- inline void clear() noexcept;
- inline void maybe_grow();
- inline void grow_one();
- inline void grow(std::size_t nchars);
- inline void append(string_view s);
- inline string_view release_string() noexcept;
- inline value* release(std::size_t n) noexcept;
- template<class... Args> value& push(Args&&... args);
- template<class Unchecked> void exchange(Unchecked&& u);
- };
- stack st_;
- storage_ptr sp_;
- public:
-
- value_stack(
- value_stack const&) = delete;
-
- value_stack& operator=(
- value_stack const&) = delete;
-
- BOOST_JSON_DECL
- ~value_stack();
-
- BOOST_JSON_DECL
- value_stack(
- storage_ptr sp = {},
- unsigned char* temp_buffer = nullptr,
- std::size_t temp_size = 0) noexcept;
-
- BOOST_JSON_DECL
- void
- reset(storage_ptr sp = {}) noexcept;
-
- BOOST_JSON_DECL
- value
- release() noexcept;
-
-
- BOOST_JSON_DECL
- void
- push_array(std::size_t n);
-
- BOOST_JSON_DECL
- void
- push_object(std::size_t n);
-
- BOOST_JSON_DECL
- void
- push_chars(
- string_view s);
-
- BOOST_JSON_DECL
- void
- push_key(
- string_view s);
-
- BOOST_JSON_DECL
- void
- push_string(
- string_view s);
-
- BOOST_JSON_DECL
- void
- push_int64(
- int64_t i);
-
- BOOST_JSON_DECL
- void
- push_uint64(
- uint64_t u);
-
- BOOST_JSON_DECL
- void
- push_double(
- double d);
-
- BOOST_JSON_DECL
- void
- push_bool(
- bool b);
-
- BOOST_JSON_DECL
- void
- push_null();
- };
- }
- }
- #endif
|