libpqxx  7.9.0
pqxx::array_parser Class Reference

Low-level array parser. More...

#include <array.hxx>

Public Types

enum class  juncture {
  row_start , row_end , null_value , string_value ,
  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.

Warning
This is not a great API. Something nicer is on the way.

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

Warning
This parser will only work reliably if your client encoding is UTF-8, ASCII, or a "safe ASCII superset" (such as the EUC encodings) where a byte value in the ASCII range can only occur as an actual ASCII character, never as one byte in a multi-byte character.
The parser only supports array element types which use a comma (‘’,') as the separator between array elements. All built-in SQL types use comma, except forbox` which uses semicolon. However 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.

The parser only remains valid while the data underlying the result remains valid. Once all result objects referring to that data have been destroyed, the parser will no longer refer to valid memory.

Member Function Documentation

◆ get_next()

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

Parse the next step in the array.

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

Call this until the array_parser::juncture it returns is juncture::done.


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