Kea 2.7.6
isc::data::Element::Position Struct Reference

Represents the position of the data element within a configuration string. More...

#include <data.h>

Public Member Functions

 Position ()
 Default constructor.
 
 Position (const std::string &file, const uint32_t line, const uint32_t pos)
 Constructor.
 
std::string str () const
 Returns the position in the textual format.
 

Public Attributes

std::string file_
 File name.
 
uint32_t line_
 Line number.
 
uint32_t pos_
 Position within the line.
 

Detailed Description

Represents the position of the data element within a configuration string.

Position comprises a file name, line number and an offset within this line where the element value starts. For example, if the JSON string is

{ "foo": "some string",
"bar": 123 }

the position of the element "bar" is: line_ = 2; pos_ = 9, because beginning of the value "123" is at offset 9 from the beginning of the second line, including whitespaces.

Note that the Position structure is used as an argument to Element constructors and factory functions to avoid ambiguity and so that the uint32_t arguments holding line number and position within the line are not confused with the Element values passed to these functions.

Definition at line 94 of file data.h.

Constructor & Destructor Documentation

◆ Position() [1/2]

isc::data::Element::Position::Position ( )
inline

Default constructor.

Definition at line 100 of file data.h.

◆ Position() [2/2]

isc::data::Element::Position::Position ( const std::string & file,
const uint32_t line,
const uint32_t pos )
inline

Constructor.

Parameters
fileFile name.
lineLine number.
posPosition within the line.

Definition at line 108 of file data.h.

Member Function Documentation

◆ str()

std::string isc::data::Element::Position::str ( ) const

Returns the position in the textual format.

The returned position has the following format: file:line:pos.

Definition at line 41 of file data.cc.

References file_, line_, and pos_.

Referenced by isc::data::operator<<().

Member Data Documentation

◆ file_

std::string isc::data::Element::Position::file_

File name.

Definition at line 95 of file data.h.

Referenced by str().

◆ line_

uint32_t isc::data::Element::Position::line_

Line number.

Definition at line 96 of file data.h.

Referenced by str().

◆ pos_

uint32_t isc::data::Element::Position::pos_

Position within the line.

Definition at line 97 of file data.h.

Referenced by str().


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