Version: SMASH-3.4
smash::InputSections::Section Struct Reference

#include <input_keys.h>

A simple struct to represent input sections.

This struct contains a raw pointer to the parent section and the name of the section itself. The parent pointer is used to reconstruct the full path of labels to reach a given section from the top-level section. This is needed to declare Key objects which need the full path of labels. A Section can be implicitly converted to KeyLabels and this is desired by design (after all a YAML section is a key with a map as value).

Attention
Objects of type Section are meant to be created at compile time and they are not meant to be ever modified (note the constexpr constructor). This is a crucial aspect that guarantees that compile-time construction of sections will not hit any SIOF issue. Materialization into KeyLabels is done at runtime when InputKeys members are initialized.

Definition at line 64 of file input_keys.h.

Collaboration diagram for smash::InputSections::Section:
[legend]

Public Member Functions

constexpr Section (std::string_view name_in, const Section *parent_in=nullptr)
 Construct a new section. More...
 
 operator KeyLabels () const
 Convert the section to a list of labels. More...
 

Public Attributes

const Section *const parent = nullptr
 A pointer to the parent section. More...
 
const std::string_view name = ""
 The name of the section. More...
 

Private Member Functions

KeyLabels materialize () const
 Materialize the section into a list of labels. More...
 

Constructor & Destructor Documentation

◆ Section()

constexpr smash::InputSections::Section::Section ( std::string_view  name_in,
const Section parent_in = nullptr 
)
inlineexplicitconstexpr

Construct a new section.

Parameters
name_inThe name of the section
parent_inA pointer to the parent section

Definition at line 76 of file input_keys.h.

78  : parent{parent_in}, name{name_in} {}
const std::string_view name
The name of the section.
Definition: input_keys.h:68
const Section *const parent
A pointer to the parent section.
Definition: input_keys.h:66

Member Function Documentation

◆ operator KeyLabels()

smash::InputSections::Section::operator KeyLabels ( ) const
inline

Convert the section to a list of labels.

Returns
A list of labels representing the full path to the section

Definition at line 85 of file input_keys.h.

85 { return materialize(); }
KeyLabels materialize() const
Materialize the section into a list of labels.
Definition: input_keys.h:93
Here is the call graph for this function:

◆ materialize()

KeyLabels smash::InputSections::Section::materialize ( ) const
inlineprivate

Materialize the section into a list of labels.

Returns
A list of labels representing the full path to the section

Definition at line 93 of file input_keys.h.

93  {
94  KeyLabels labels = {name};
95  auto current = parent;
96  while (current) {
97  labels.emplace_back(current->name);
98  current = current->parent;
99  }
100  std::reverse(labels.begin(), labels.end());
101  return labels;
102  }
std::vector< std::string_view > KeyLabels
Descriptive alias for storing key labels, i.e.
Definition: key.h:46
Here is the caller graph for this function:

Member Data Documentation

◆ parent

const Section* const smash::InputSections::Section::parent = nullptr

A pointer to the parent section.

Definition at line 66 of file input_keys.h.

◆ name

const std::string_view smash::InputSections::Section::name = ""

The name of the section.

Definition at line 68 of file input_keys.h.


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