libpqxx  7.0.7
array.hxx
1 /* Handling of SQL arrays.
2  *
3  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/field instead.
4  *
5  * Copyright (c) 2000-2020, Jeroen T. Vermeulen.
6  *
7  * See COPYING for copyright license. If you did not receive a file called
8  * COPYING with this source code, please notify the distributor of this
9  * mistake, or contact the author.
10  */
11 #ifndef PQXX_H_ARRAY
12 #define PQXX_H_ARRAY
13 
14 #include "pqxx/compiler-public.hxx"
15 #include "pqxx/internal/compiler-internal-pre.hxx"
16 
17 #include "pqxx/internal/encoding_group.hxx"
18 #include "pqxx/internal/encodings.hxx"
19 
20 #include <stdexcept>
21 #include <string>
22 #include <utility>
23 
24 
25 namespace pqxx
26 {
28 
46 class PQXX_LIBEXPORT array_parser
47 {
48 public:
50  enum class juncture
51  {
53  row_start,
55  row_end,
57  null_value,
59  string_value,
61  done,
62  };
63 
65  explicit array_parser(
66  std::string_view input,
67  internal::encoding_group = internal::encoding_group::MONOBYTE);
68 
70 
75  std::pair<juncture, std::string> get_next();
76 
77 private:
78  std::string_view m_input;
79  internal::glyph_scanner_func *const m_scan;
80 
82  std::string::size_type m_pos;
83 
84  std::string::size_type scan_single_quoted_string() const;
85  std::string parse_single_quoted_string(std::string::size_type end) const;
86  std::string::size_type scan_double_quoted_string() const;
87  std::string parse_double_quoted_string(std::string::size_type end) const;
88  std::string::size_type scan_unquoted_string() const;
89  std::string parse_unquoted_string(std::string::size_type end) const;
90 
91  std::string::size_type scan_glyph(std::string::size_type pos) const;
92  std::string::size_type
93  scan_glyph(std::string::size_type pos, std::string::size_type end) const;
94 };
95 } // namespace pqxx
96 
97 #include "pqxx/internal/compiler-internal-post.hxx"
98 #endif
pqxx::array_parser::juncture::row_start
@ row_start
Starting a new row.
pqxx::array_parser::juncture::string_value
@ string_value
Found a string value.
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
pqxx::array_parser::array_parser
array_parser(std::string_view input, internal::encoding_group=internal::encoding_group::MONOBYTE)
Constructor. You don't need this; use field::as_array instead.
Definition: array.cxx:189
pqxx::array_parser::juncture::null_value
@ null_value
Found a NULL value.
pqxx::array_parser::juncture::row_end
@ row_end
Ending the current row.
pqxx::failure
Run-time failure encountered by libpqxx, similar to std::runtime_error.
Definition: except.hxx:42
pqxx::array_parser::get_next
std::pair< juncture, std::string > get_next()
Parse the next step in the array.
Definition: array.cxx:197
pqxx::array_parser::juncture::done
@ done
Parsing has completed.
pqxx::array_parser
Low-level array parser.
Definition: array.hxx:46
pqxx::array_parser::juncture
juncture
What's the latest thing found in the array?
Definition: array.hxx:50