LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::Spec Struct Reference

#include <bwf_base.h>

Collaboration diagram for swoc::Spec:
Collaboration graph

Classes

struct  Property
 Handrolled initialization the character syntactic property data. More...
 

Public Types

enum class  Align : char {
  NONE , LEFT , RIGHT , CENTER ,
  SIGN
}
 Flag for how to align the output inside a limited width field. More...
 
using self_type = Spec
 Self reference type.
 

Public Member Functions

constexpr Spec ()
 Constructor a default instance.
 
 Spec (const TextView &fmt)
 Construct by parsing fmt.
 
bool parse (TextView fmt)
 Parse a format specification.
 
bool has_numeric_type () const
 Check if the type in this is numeric.
 
bool has_upper_case_type () const
 Check if the type in this is an upper case variant.
 
bool has_pointer_type () const
 Check if the type is a raw pointer.
 
bool has_valid_type () const
 Check if the type is valid.
 

Static Public Member Functions

static bool is_type (char c)
 Validate c is a specifier type indicator.
 
static bool is_numeric_type (char c)
 Check if the type flag is numeric.
 
static bool is_upper_case_type (char c)
 Check if the type is an upper case variant.
 

Public Attributes

char _fill = ' '
 Fill character.
 
char _sign = SIGN_NEG
 
enum swoc::bwf::Spec::Align _align = Align::NONE
 Output field alignment.
 
char _type = DEFAULT_TYPE
 Type / radix indicator.
 
bool _radix_lead_p = false
 Print leading radix indication.
 
unsigned int _min = 0
 Minimum width.
 
int _prec = -1
 Precision.
 
unsigned int _max = std::numeric_limits<unsigned int>::max()
 Maximum width.
 
int _idx = -1
 Positional "name" of the specification.
 
std::string_view _name
 Name of the specification.
 
std::string_view _ext
 Extension if provided.
 

Static Public Attributes

static constexpr char DEFAULT_TYPE = 'g'
 Default format type.
 
static constexpr char INVALID_TYPE = 0
 Type for missing or invalid specifier.
 
static constexpr char LITERAL_TYPE = '"'
 Internal type to mark a literal.
 
static constexpr char CAPTURE_TYPE = 1
 Internal type to mark a capture.
 
static constexpr char SIGN_ALWAYS = '+'
 Always print a sign character.
 
static constexpr char SIGN_NEVER = ' '
 Never print a sign character.
 
static constexpr char SIGN_NEG = '-'
 Print a sign character only for negative values (default).
 
static const self_type DEFAULT
 Global default instance for use in situations where a format specifier isn't available.
 

Protected Member Functions

Align align_of (char c)
 Validate character is alignment character and return the appropriate enum value.
 
bool is_sign (char c)
 Validate is sign indicator.
 

Static Protected Member Functions

static const PropertyGet_Prop ()
 Character property map.
 

Detailed Description

Parsed version of a format specifier.

Literals are represented as an instance of this class, with the type set to LITERAL_TYPE and the literal text in the _ext field.

Definition at line 37 of file bwf_base.h.

Member Typedef Documentation

◆ self_type

Self reference type.

Definition at line 38 of file bwf_base.h.

Member Enumeration Documentation

◆ Align

enum class swoc::bwf::Spec::Align : char
strong

Flag for how to align the output inside a limited width field.

Enumerator
NONE 

No alignment.

LEFT 

Left alignment '<'.

RIGHT 

Right alignment '>'.

CENTER 

Center alignment '^'.

SIGN 

Align plus/minus sign before numeric fill. '='.

Definition at line 62 of file bwf_base.h.

Constructor & Destructor Documentation

◆ Spec() [1/2]

swoc::bwf::Spec::Spec ( )
inlineconstexpr

Constructor a default instance.

Definition at line 50 of file bwf_base.h.

◆ Spec() [2/2]

swoc::bwf::Spec::Spec ( const TextView & fmt)

Construct by parsing fmt.

Definition at line 66 of file bw_format.cc.

Member Function Documentation

◆ align_of()

Spec::Align swoc::bwf::Spec::align_of ( char c)
inlineprotected

Validate character is alignment character and return the appropriate enum value.

Spec

Definition at line 482 of file bwf_base.h.

◆ Get_Prop()

static const Property & swoc::bwf::Spec::Get_Prop ( )
inlinestaticprotected

Character property map.

Definition at line 123 of file bwf_base.h.

◆ has_numeric_type()

bool swoc::bwf::Spec::has_numeric_type ( ) const
inline

Check if the type in this is numeric.

Definition at line 507 of file bwf_base.h.

◆ has_pointer_type()

bool swoc::bwf::Spec::has_pointer_type ( ) const
inline

Check if the type is a raw pointer.

Definition at line 517 of file bwf_base.h.

◆ has_upper_case_type()

bool swoc::bwf::Spec::has_upper_case_type ( ) const
inline

Check if the type in this is an upper case variant.

Definition at line 512 of file bwf_base.h.

◆ has_valid_type()

bool swoc::bwf::Spec::has_valid_type ( ) const
inline

Check if the type is valid.

Definition at line 522 of file bwf_base.h.

◆ is_numeric_type()

bool swoc::bwf::Spec::is_numeric_type ( char c)
inlinestatic

Check if the type flag is numeric.

Definition at line 502 of file bwf_base.h.

◆ is_sign()

bool swoc::bwf::Spec::is_sign ( char c)
inlineprotected

Validate is sign indicator.

Definition at line 487 of file bwf_base.h.

◆ is_type()

bool swoc::bwf::Spec::is_type ( char c)
inlinestatic

Validate c is a specifier type indicator.

Definition at line 492 of file bwf_base.h.

◆ is_upper_case_type()

bool swoc::bwf::Spec::is_upper_case_type ( char c)
inlinestatic

Check if the type is an upper case variant.

Definition at line 497 of file bwf_base.h.

◆ parse()

bool swoc::bwf::Spec::parse ( TextView fmt)

Parse a format specification.

Parse a specifier. State is not reset, this should be default constructed before calling.

Definition at line 72 of file bw_format.cc.

Member Data Documentation

◆ _ext

std::string_view swoc::bwf::Spec::_ext

Extension if provided.

Definition at line 77 of file bwf_base.h.

◆ _fill

char swoc::bwf::Spec::_fill = ' '

Fill character.

Definition at line 59 of file bwf_base.h.

◆ _idx

int swoc::bwf::Spec::_idx = -1

Positional "name" of the specification.

Definition at line 75 of file bwf_base.h.

◆ _max

unsigned int swoc::bwf::Spec::_max = std::numeric_limits<unsigned int>::max()

Maximum width.

Definition at line 74 of file bwf_base.h.

◆ _min

unsigned int swoc::bwf::Spec::_min = 0

Minimum width.

Definition at line 72 of file bwf_base.h.

◆ _name

std::string_view swoc::bwf::Spec::_name

Name of the specification.

Definition at line 76 of file bwf_base.h.

◆ _prec

int swoc::bwf::Spec::_prec = -1

Precision.

Definition at line 73 of file bwf_base.h.

◆ _radix_lead_p

bool swoc::bwf::Spec::_radix_lead_p = false

Print leading radix indication.

Definition at line 70 of file bwf_base.h.

◆ _sign

char swoc::bwf::Spec::_sign = SIGN_NEG

Numeric sign style.

Definition at line 60 of file bwf_base.h.

◆ _type

char swoc::bwf::Spec::_type = DEFAULT_TYPE

Type / radix indicator.

Definition at line 69 of file bwf_base.h.

◆ CAPTURE_TYPE

char swoc::bwf::Spec::CAPTURE_TYPE = 1
staticconstexpr

Internal type to mark a capture.

Definition at line 43 of file bwf_base.h.

◆ DEFAULT

const Spec swoc::bwf::Spec::DEFAULT
static

Global default instance for use in situations where a format specifier isn't available.

Definition at line 80 of file bwf_base.h.

◆ DEFAULT_TYPE

char swoc::bwf::Spec::DEFAULT_TYPE = 'g'
staticconstexpr

Default format type.

Definition at line 40 of file bwf_base.h.

◆ INVALID_TYPE

char swoc::bwf::Spec::INVALID_TYPE = 0
staticconstexpr

Type for missing or invalid specifier.

Definition at line 41 of file bwf_base.h.

◆ LITERAL_TYPE

char swoc::bwf::Spec::LITERAL_TYPE = '"'
staticconstexpr

Internal type to mark a literal.

Definition at line 42 of file bwf_base.h.

◆ SIGN_ALWAYS

char swoc::bwf::Spec::SIGN_ALWAYS = '+'
staticconstexpr

Always print a sign character.

Definition at line 45 of file bwf_base.h.

◆ SIGN_NEG

char swoc::bwf::Spec::SIGN_NEG = '-'
staticconstexpr

Print a sign character only for negative values (default).

Definition at line 47 of file bwf_base.h.

◆ SIGN_NEVER

char swoc::bwf::Spec::SIGN_NEVER = ' '
staticconstexpr

Never print a sign character.

Definition at line 46 of file bwf_base.h.


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