libpqxx  7.0.5
pqxx::array_parser Class Reference

Low-level array parser. More...

#include <array.hxx>

Public Types

enum  juncture {
  juncture::row_start, juncture::row_end, juncture::null_value, juncture::string_value,
  juncture::done
}
 What's the latest thing found in the array? More...
 

Public Member Functions

 array_parser (std::string_view input, internal::encoding_group=internal::encoding_group::MONOBYTE)
 Constructor. You don't need this; use field::as_array instead. More...
 
std::pair< juncture, std::string > get_next ()
 Parse the next step in the array. More...
 

Detailed Description

Low-level array parser.

Use this to read an array field retrieved from the database.

This parser will only work reliably if your client encoding is UTF-8, ASCII, or a single-byte encoding which is a superset of ASCII (such as Latin-1).

Also, the parser only supports array element types which use either a comma or a semicolon ("," or ";") as the separator between array elements. All built-in types use comma, except for one which uses semicolon, but some custom types may not work.

The input is a C-style string containing the textual representation of an array, as returned by the database. The parser reads this representation on the fly. The string must remain in memory until parsing is done.

Parse the array by making calls to get_next until it returns a juncture of "done". The juncture tells you what the parser found in that step: did the array "nest" to a deeper level, or "un-nest" back up?

Member Enumeration Documentation

◆ juncture

What's the latest thing found in the array?

Enumerator
row_start 

Starting a new row.

row_end 

Ending the current row.

null_value 

Found a NULL value.

string_value 

Found a string value.

done 

Parsing has completed.

Constructor & Destructor Documentation

◆ array_parser()

pqxx::array_parser::array_parser ( std::string_view  input,
internal::encoding_group  enc = internal::encoding_group::MONOBYTE 
)
explicit

Constructor. You don't need this; use field::as_array instead.

Member Function Documentation

◆ get_next()

std::pair< array_parser::juncture, std::string > pqxx::array_parser::get_next ( )

Parse the next step in the array.

Returns what it found. If the juncture is string_value, the string will contain the value. Otherwise, it will be empty.

Call this until the juncture it returns is done.

References done, null_value, row_end, row_start, and string_value.


The documentation for this class was generated from the following files: