Bifrost SDK
Bifrost SDK documentation
Amino::NamingUtilities Class Reference

A collection of Naming Utility methods. More...

#include <NamingUtilities.h>

Public Member Functions

 NamingUtilities ()=delete
 NamingUtilities are static functions only. More...
 
 NamingUtilities (const NamingUtilities &)=delete
 NamingUtilities are static functions only. More...
 
NamingUtilitiesoperator= (const NamingUtilities &)=delete
 NamingUtilities are static functions only. More...
 

Static Public Member Functions

static bool legalize (String &name)
 Convert a string to a legal name by removing invalid characters. More...
 
static bool getLegalName (StringView const &name, String &legalName)
 Convert a string to a legal name by removing invalid characters. See legalize for conversion details. More...
 
static bool isLegalName (StringView const &name)
 Check if a name is legal. More...
 

Detailed Description

A collection of Naming Utility methods.

Definition at line 36 of file NamingUtilities.h.

Constructor & Destructor Documentation

◆ NamingUtilities() [1/2]

Amino::NamingUtilities::NamingUtilities ( )
delete

NamingUtilities are static functions only.

◆ NamingUtilities() [2/2]

Amino::NamingUtilities::NamingUtilities ( const NamingUtilities )
delete

NamingUtilities are static functions only.

Member Function Documentation

◆ getLegalName()

static bool Amino::NamingUtilities::getLegalName ( StringView const &  name,
String legalName 
)
static

Convert a string to a legal name by removing invalid characters. See legalize for conversion details.

Parameters
[in]nameThe name to legalize
[out]legalNameThe output legalized name
Returns
Returns true if the legalized name is different than the original name, false otherwise.

◆ isLegalName()

static bool Amino::NamingUtilities::isLegalName ( StringView const &  name)
static

Check if a name is legal.

This method will check if a name requires clean up using the rules listed in getLegalName.

Parameters
[in]nameThe name to check
Returns
Returns true if the name is legal, false otherwise

◆ legalize()

static bool Amino::NamingUtilities::legalize ( String name)
static

Convert a string to a legal name by removing invalid characters.

This method will clean up any illegal characters from a name to make it usable by external packages and also by the compiler back-end. The cleaning rules are:

  1. Valid characters are a-z A-Z 0-9 _ (excluding spaces).
  2. If the input name is empty (which is not a legal name), the output name is a single underscore (i.e. "" becomes "_").
  3. Invalid characters at the start of the name are dropped: "+++abc" becomes "abc".
  4. If the first valid character is a digit then an underscore is inserted as the leading character: "012" becomes "_012".
  5. Invalid characters in the rest of the name are replaced with underscore.
  6. Leading underscores and illegal characters are removed leaving one underscore. If the leading underscore that is left after the removal is followed by A-Z then this character is changed to lower case: "___ABC" becomes "_aBC".
Parameters
[in,out]nameThe name to legalize
Returns
Returns true if the legalized name is different than the original name, false otherwise.

◆ operator=()

NamingUtilities & Amino::NamingUtilities::operator= ( const NamingUtilities )
delete

NamingUtilities are static functions only.