lxgui
Public Member Functions | Protected Attributes | List of all members
lxgui::gui::layout_attribute Class Reference

An attribute in a layout file. More...

#include <gui_layout_node.hpp>

Inheritance diagram for lxgui::gui::layout_attribute:
lxgui::gui::layout_node

Public Member Functions

 layout_attribute ()=default
 
 layout_attribute (const layout_attribute &)=default
 
 layout_attribute (layout_attribute &&)=default
 
layout_attributeoperator= (const layout_attribute &)=default
 
layout_attributeoperator= (layout_attribute &&)=default
 
std::string_view get_location () const noexcept
 Returns this node's location in the file as {file}:{line}. More...
 
std::string_view get_value_location () const noexcept
 Returns this node's value location in the file as {file}:{line}. More...
 
std::string_view get_filename () const noexcept
 Returns the file in which this node is located. More...
 
std::size_t get_line_number () const noexcept
 Returns the line number on which this node is located. More...
 
std::size_t get_value_line_number () const noexcept
 Returns the line number on which this node's value is located. More...
 
std::string_view get_name () const noexcept
 Returns this node's name. More...
 
std::string_view get_value () const noexcept
 Returns this node's value as string. More...
 
template<typename T >
std::optional< T > try_get_value () const noexcept
 Returns this node's value converted to a specific type, or nullopt if conversion failed. More...
 
template<typename T >
get_value () const
 Returns this node's value converted to a specific type. More...
 
template<typename T >
get_value_or (T fallback) const noexcept
 Returns this node's value converted to a specific type, or a default value. More...
 
void set_location (std::string location) noexcept
 Set this node's location. More...
 
void set_value_location (std::string location) noexcept
 Set this node's value location. More...
 
void set_name (std::string name) noexcept
 Set this node's name. More...
 
void set_value (std::string value) noexcept
 Set this node's value. More...
 
void mark_as_not_accessed () const noexcept
 Flag this node as "not accessed" for later warnings. More...
 
void bypass_access_check () const noexcept
 Flag this node as "fully accessed" for later warnings; no check will be done. More...
 
bool was_accessed () const noexcept
 Check if this node was accessed by the parser. More...
 
bool is_access_check_bypassed () const noexcept
 Check if this node should be bypassed for access checks. More...
 

Protected Attributes

std::string name_
 
std::string value_
 
std::string location_
 
std::string value_location_
 
bool accessed_ = false
 
bool access_bypass_ = false
 

Detailed Description

An attribute in a layout file.

This is a format-agnostic representation of a GUI layout, as read for example from an XML or YAML file. The GUI uses this class to de-couple the layout parsing format (XML, YAML, etc) from the actual parsed layout.

Definition at line 24 of file gui_layout_node.hpp.

Constructor & Destructor Documentation

◆ layout_attribute() [1/3]

lxgui::gui::layout_attribute::layout_attribute ( )
default

◆ layout_attribute() [2/3]

lxgui::gui::layout_attribute::layout_attribute ( const layout_attribute )
default

◆ layout_attribute() [3/3]

lxgui::gui::layout_attribute::layout_attribute ( layout_attribute &&  )
default

Member Function Documentation

◆ bypass_access_check()

void lxgui::gui::layout_attribute::bypass_access_check ( ) const
inlinenoexcept

Flag this node as "fully accessed" for later warnings; no check will be done.

Definition at line 193 of file gui_layout_node.hpp.

◆ get_filename()

std::string_view lxgui::gui::layout_attribute::get_filename ( ) const
inlinenoexcept

Returns the file in which this node is located.

Returns
The file in which this node is located

Definition at line 52 of file gui_layout_node.hpp.

◆ get_line_number()

std::size_t lxgui::gui::layout_attribute::get_line_number ( ) const
inlinenoexcept

Returns the line number on which this node is located.

Returns
The line number on which this node is located

Definition at line 61 of file gui_layout_node.hpp.

◆ get_location()

std::string_view lxgui::gui::layout_attribute::get_location ( ) const
inlinenoexcept

Returns this node's location in the file as {file}:{line}.

Returns
This node's location in the file as {file}:{line}

Definition at line 36 of file gui_layout_node.hpp.

◆ get_name()

std::string_view lxgui::gui::layout_attribute::get_name ( ) const
inlinenoexcept

Returns this node's name.

Returns
This node's name

Definition at line 87 of file gui_layout_node.hpp.

◆ get_value() [1/2]

template<typename T >
T lxgui::gui::layout_attribute::get_value ( ) const
inline

Returns this node's value converted to a specific type.

Returns
This node's value converted to a specific type
Note
Will throw if the value could not be converted. Use get_value_or() to avoid throwing.

Definition at line 124 of file gui_layout_node.hpp.

◆ get_value() [2/2]

std::string_view lxgui::gui::layout_attribute::get_value ( ) const
inlinenoexcept

Returns this node's value as string.

Returns
This node's value as string
Note
Returns an empty string if none

Definition at line 96 of file gui_layout_node.hpp.

◆ get_value_line_number()

std::size_t lxgui::gui::layout_attribute::get_value_line_number ( ) const
inlinenoexcept

Returns the line number on which this node's value is located.

Returns
The line number on which this node's value is located

Definition at line 74 of file gui_layout_node.hpp.

◆ get_value_location()

std::string_view lxgui::gui::layout_attribute::get_value_location ( ) const
inlinenoexcept

Returns this node's value location in the file as {file}:{line}.

Returns
This node's value location in the file as {file}:{line}

Definition at line 44 of file gui_layout_node.hpp.

◆ get_value_or()

template<typename T >
T lxgui::gui::layout_attribute::get_value_or ( fallback) const
inlinenoexcept

Returns this node's value converted to a specific type, or a default value.

Returns
This node's value converted to a specific type, or a default value
Note
Will return the default value if the value could not be converted.

Definition at line 142 of file gui_layout_node.hpp.

◆ is_access_check_bypassed()

bool lxgui::gui::layout_attribute::is_access_check_bypassed ( ) const
inlinenoexcept

Check if this node should be bypassed for access checks.

Returns
'true' if this node should be bypassed, 'false' otherwise.

Definition at line 209 of file gui_layout_node.hpp.

◆ mark_as_not_accessed()

void lxgui::gui::layout_attribute::mark_as_not_accessed ( ) const
inlinenoexcept

Flag this node as "not accessed" for later warnings.

Definition at line 188 of file gui_layout_node.hpp.

◆ operator=() [1/2]

layout_attribute& lxgui::gui::layout_attribute::operator= ( const layout_attribute )
default

◆ operator=() [2/2]

layout_attribute& lxgui::gui::layout_attribute::operator= ( layout_attribute &&  )
default

◆ set_location()

void lxgui::gui::layout_attribute::set_location ( std::string  location)
inlinenoexcept

Set this node's location.

Parameters
locationThe new location

Definition at line 159 of file gui_layout_node.hpp.

◆ set_name()

void lxgui::gui::layout_attribute::set_name ( std::string  name)
inlinenoexcept

Set this node's name.

Parameters
nameThe new name

Definition at line 175 of file gui_layout_node.hpp.

◆ set_value()

void lxgui::gui::layout_attribute::set_value ( std::string  value)
inlinenoexcept

Set this node's value.

Parameters
valueThe new value

Definition at line 183 of file gui_layout_node.hpp.

◆ set_value_location()

void lxgui::gui::layout_attribute::set_value_location ( std::string  location)
inlinenoexcept

Set this node's value location.

Parameters
locationThe new value location

Definition at line 167 of file gui_layout_node.hpp.

◆ try_get_value()

template<typename T >
std::optional<T> lxgui::gui::layout_attribute::try_get_value ( ) const
inlinenoexcept

Returns this node's value converted to a specific type, or nullopt if conversion failed.

Returns
This node's value converted to a specific type, or nullopt if conversion failed

Definition at line 106 of file gui_layout_node.hpp.

◆ was_accessed()

bool lxgui::gui::layout_attribute::was_accessed ( ) const
inlinenoexcept

Check if this node was accessed by the parser.

Returns
'true' if this node was accessed by the parser, 'false' otherwise.

Definition at line 201 of file gui_layout_node.hpp.

Member Data Documentation

◆ access_bypass_

bool lxgui::gui::layout_attribute::access_bypass_ = false
mutableprotected

Definition at line 220 of file gui_layout_node.hpp.

◆ accessed_

bool lxgui::gui::layout_attribute::accessed_ = false
mutableprotected

Definition at line 219 of file gui_layout_node.hpp.

◆ location_

std::string lxgui::gui::layout_attribute::location_
protected

Definition at line 216 of file gui_layout_node.hpp.

◆ name_

std::string lxgui::gui::layout_attribute::name_
protected

Definition at line 214 of file gui_layout_node.hpp.

◆ value_

std::string lxgui::gui::layout_attribute::value_
protected

Definition at line 215 of file gui_layout_node.hpp.

◆ value_location_

std::string lxgui::gui::layout_attribute::value_location_
protected

Definition at line 217 of file gui_layout_node.hpp.


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