libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
NumName Class Reference

Deconstructs a numbered name into its prefix, number, and suffix components. More...

#include <numname.h>

Public Member Functions

 NumName ()=default
 Constructs an invalid (empty) NumName.
 
 NumName (const String &prefix, const String &suffix, int digits, bool padded)
 Constructs a NumName from explicit components.
 
 NumName (const String &str)
 Constructs a NumName by parsing a string.
 
bool isValid () const
 Checks whether this NumName contains a valid numeric field.
 
String name (int val) const
 Generates a full name string with the given numeric value.
 
String prefix () const
 Returns the prefix portion of the name (text before the number).
 
String suffix () const
 Returns the suffix portion of the name (text after the number).
 
bool isPadded () const
 Checks whether the numeric field is zero-padded.
 
int digits () const
 Returns the number of digits in the numeric field.
 
String filemask () const
 Returns a C-style printf format mask for the numbered name.
 
String hashmask () const
 Returns a hash-style mask for the numbered name.
 
bool operator== (const NumName &other) const
 Returns true if both NumNames have identical components.
 
bool operator!= (const NumName &other) const
 Returns true if the NumNames differ in any component.
 
bool isInSequence (const NumName &n) const
 Checks whether another NumName belongs to the same sequence.
 

Static Public Member Functions

static NumName parse (const String &str, int *val=nullptr)
 Parses a string into a NumName.
 

Detailed Description

Deconstructs a numbered name into its prefix, number, and suffix components.

Parses strings like "fred-0001", "007 Bond", or "test.098.dpx" into a prefix, a numeric field (with optional zero-padding), and a suffix. Useful for working with numbered file sequences.

Constructor & Destructor Documentation

◆ NumName() [1/2]

NumName::NumName ( const String prefix,
const String suffix,
int  digits,
bool  padded 
)
inline

Constructs a NumName from explicit components.

Parameters
prefixThe string before the number.
suffixThe string after the number.
digitsThe number of digits (including padding).
paddedTrue if the number is zero-padded.

◆ NumName() [2/2]

NumName::NumName ( const String str)
inline

Constructs a NumName by parsing a string.

Parameters
strThe string to parse.

Member Function Documentation

◆ digits()

int NumName::digits ( ) const
inline

Returns the number of digits in the numeric field.

Returns
The digit count, including any padding digits.

◆ filemask()

String NumName::filemask ( ) const
inline

Returns a C-style printf format mask for the numbered name.

For example, "file.1234.dpx" yields "file.%d.dpx" and "file.01234.dpx" yields "file.%05d.dpx".

Returns
The format mask string.

◆ hashmask()

String NumName::hashmask ( ) const
inline

Returns a hash-style mask for the numbered name.

For example, "file.1234.dpx" yields "file.#.dpx" and "file.01234.dpx" yields "file.#####.dpx".

Returns
The hash mask string.

◆ isInSequence()

bool NumName::isInSequence ( const NumName n) const
inline

Checks whether another NumName belongs to the same sequence.

Two NumNames are in the same sequence if they share the same prefix and suffix, and their padding/digit configuration is compatible.

Parameters
nThe NumName to compare against.
Returns
True if n could be part of the same numbered sequence.

◆ isPadded()

bool NumName::isPadded ( ) const
inline

Checks whether the numeric field is zero-padded.

Returns
True if the number is padded with leading zeros.

◆ isValid()

bool NumName::isValid ( ) const
inline

Checks whether this NumName contains a valid numeric field.

Returns
True if at least one digit was found.

◆ name()

String NumName::name ( int  val) const
inline

Generates a full name string with the given numeric value.

Parameters
valThe number to insert into the name.
Returns
The assembled string (prefix + formatted number + suffix).

◆ parse()

static NumName NumName::parse ( const String str,
int *  val = nullptr 
)
static

Parses a string into a NumName.

Parameters
strThe string to parse.
valOptional output for the parsed numeric value.
Returns
The parsed NumName, or an invalid NumName if no number is found.

◆ prefix()

String NumName::prefix ( ) const
inline

Returns the prefix portion of the name (text before the number).

Returns
The prefix string.

◆ suffix()

String NumName::suffix ( ) const
inline

Returns the suffix portion of the name (text after the number).

Returns
The suffix string.

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