C++ Device API Reference Manual
Reference documentation for the Simics C++ Device API.
 
Loading...
Searching...
No Matches
simics::detail::HierarchicalObjectName Class Reference

Represents name of a bank/register/field. More...

#include <hierarchical-object-name.h>

Inheritance diagram for simics::detail::HierarchicalObjectName:

Public Member Functions

constexpr HierarchicalObjectName () noexcept
 
constexpr HierarchicalObjectName (const HierarchicalObjectName &other) noexcept=default
 
constexpr HierarchicalObjectName (const_pointer s, size_type count)
 
constexpr HierarchicalObjectName (const_pointer s)
 
constexpr std::string_view base_name () const
 
constexpr std::string_view array_str () const
 
std::map< std::string, size_t > arrayNamesToOffsets (size_t width) const
 Generates a mapping of array names to their corresponding memory offsets.
 
std::vector< std::pair< size_t, size_t > > arraySizesAndStrides () const
 Parses a string representation of array dimensions to extract sizes and strides.
 

Static Public Member Functions

static constexpr void validate_name (std::string_view name)
 Validates the format of a name, ensuring it adheres to specific rules.
 

Detailed Description

Represents name of a bank/register/field.

The name should be aligned with the hierarchical object name format:

  • The name must not be empty. An exception is thrown if the name is empty.
  • The name must begin with an alphabetic character.
  • The base name (without array notation) must consist only of alphanumeric characters and underscores ('_').
  • The array notation is enclosed in square brackets ('[' and ']').

Constructor & Destructor Documentation

◆ HierarchicalObjectName() [1/4]

constexpr simics::detail::HierarchicalObjectName::HierarchicalObjectName ( )
inlineconstexprnoexcept

◆ HierarchicalObjectName() [2/4]

constexpr simics::detail::HierarchicalObjectName::HierarchicalObjectName ( const HierarchicalObjectName other)
constexprdefaultnoexcept

◆ HierarchicalObjectName() [3/4]

constexpr simics::detail::HierarchicalObjectName::HierarchicalObjectName ( const_pointer  s,
size_type  count 
)
inlineconstexpr

◆ HierarchicalObjectName() [4/4]

constexpr simics::detail::HierarchicalObjectName::HierarchicalObjectName ( const_pointer  s)
inlineconstexpr

Member Function Documentation

◆ array_str()

constexpr std::string_view simics::detail::HierarchicalObjectName::array_str ( ) const
inlineconstexpr
Returns
The array information without base name

◆ arrayNamesToOffsets()

std::map< std::string, size_t > simics::detail::HierarchicalObjectName::arrayNamesToOffsets ( size_t  width) const
inline

Generates a mapping of array names to their corresponding memory offsets.

This function calculates the offsets for array elements based on their names and dimensions, using the specified width for the innermost dimension's stride. It returns a map where each key is a string representing the name of an array element, and each value is the calculated offset for that element.

Parameters
widthThe width used as the stride for the innermost dimension.
Returns
A map where each key is a string representing an array element's name, and each value is the calculated offset for that element.

◆ arraySizesAndStrides()

std::vector< std::pair< size_t, size_t > > simics::detail::HierarchicalObjectName::arraySizesAndStrides ( ) const
inline

Parses a string representation of array dimensions to extract sizes and strides.

This function processes a string obtained from array_str() to determine the sizes and strides of array dimensions, returning them as a vector of pairs. Each pair consists of a size and a stride for a dimension.

Returns
A vector of pairs, where each pair contains the size and stride of a dimension.
Exceptions
std::logic_errorif the input string is malformed or contains invalid dimensions.

◆ base_name()

constexpr std::string_view simics::detail::HierarchicalObjectName::base_name ( ) const
inlineconstexpr
Returns
The base name without array information

◆ validate_name()

static constexpr void simics::detail::HierarchicalObjectName::validate_name ( std::string_view  name)
inlinestaticconstexpr

Validates the format of a name, ensuring it adheres to specific rules.

This constexpr function checks the validity of a name by enforcing the following constraints:

  • The name must not be empty. An exception is thrown if the name is empty.
  • The name must begin with an alphabetic character. If the first character is not alphabetic, an exception is thrown with a descriptive error message.
  • The base name must consist only of alphanumeric characters and underscores ('_'). Any other character will result in an exception being thrown, indicating the invalid character.

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