Skip to main content

FormatSpec Struct

Thin wrapper around FormatTag with implicit string conversions. More...

Declaration

struct simaai::neat::FormatSpec { ... }

Included Headers

#include <FormatSpec.h>

Public Constructors Index

constexprFormatSpec ()=default

Default-construct as unset (Auto). More...

constexprFormatSpec (FormatTag value)

Construct from a FormatTag value. More...

FormatSpec (const std::string &value)

Parse from a string token (case-insensitive); unknown tokens become Auto. More...

FormatSpec (const char *value)

Parse from a C string token; null pointer treated as empty. More...

Public Operators Index

FormatSpec &operator= (FormatTag value)

Assign from a FormatTag. More...

FormatSpec &operator= (const std::string &value)

Assign from a parsed string token. More...

FormatSpec &operator= (const char *value)

Assign from a parsed C string token. More...

booloperator== (const FormatSpec &other) const

Equality compares the underlying tag. More...

booloperator!= (const FormatSpec &other) const

Inequality compares the underlying tag. More...

operator bool () const

True iff the tag is set (anything other than Auto). More...

operator std::string () const

Implicit conversion to canonical string token. More...

Public Member Functions Index

boolempty () const

True iff the tag is Auto (unset). More...

std::stringstr () const

Canonical string form of the tag. More...

Public Member Attributes Index

FormatTagtag = FormatTag::Auto

Underlying tag (defaults to unset). More...

Description

Thin wrapper around FormatTag with implicit string conversions.

Used in option structs and caps fields where a format may arrive as either a FormatTag enum value or a string token. Implicit conversions to/from std::string keep call sites compact; the empty() and operator bool() predicates both treat Auto as "unset".

See Also

FormatTag

Definition at line 276 of file FormatSpec.h.

Public Constructors

FormatSpec()

constexpr simaai::neat::FormatSpec::FormatSpec ()
constexpr default

Default-construct as unset (Auto).

Definition at line 280 of file FormatSpec.h.

FormatSpec()

constexpr simaai::neat::FormatSpec::FormatSpec (FormatTag value)
inline constexpr

Construct from a FormatTag value.

Definition at line 282 of file FormatSpec.h.

282 constexpr FormatSpec(FormatTag value) : tag(value) {}

FormatSpec()

simaai::neat::FormatSpec::FormatSpec (const std::string & value)
inline

Parse from a string token (case-insensitive); unknown tokens become Auto.

Definition at line 284 of file FormatSpec.h.

284 FormatSpec(const std::string& value) : tag(format_tag_from_string(value)) {}

FormatSpec()

simaai::neat::FormatSpec::FormatSpec (const char * value)
inline

Parse from a C string token; null pointer treated as empty.

Definition at line 286 of file FormatSpec.h.

286 FormatSpec(const char* value)
287 : tag(format_tag_from_string(value ? std::string(value) : std::string{})) {}

Public Operators

operator bool()

simaai::neat::FormatSpec::operator bool ()
inline explicit

True iff the tag is set (anything other than Auto).

Definition at line 322 of file FormatSpec.h.

322 explicit operator bool() const {
323 return tag != FormatTag::Auto;
324 }

operator std::string()

simaai::neat::FormatSpec::operator std::string ()
inline

Implicit conversion to canonical string token.

Definition at line 326 of file FormatSpec.h.

326 operator std::string() const {
327 return str();
328 }

operator!=()

bool simaai::neat::FormatSpec::operator!= (const FormatSpec & other)
inline

Inequality compares the underlying tag.

Definition at line 314 of file FormatSpec.h.

314 bool operator!=(const FormatSpec& other) const {
315 return tag != other.tag;
316 }

operator=()

FormatSpec & simaai::neat::FormatSpec::operator= (FormatTag value)
inline

Assign from a FormatTag.

Definition at line 290 of file FormatSpec.h.

291 tag = value;
292 return *this;
293 }

operator=()

FormatSpec & simaai::neat::FormatSpec::operator= (const std::string & value)
inline

Assign from a parsed string token.

Definition at line 295 of file FormatSpec.h.

295 FormatSpec& operator=(const std::string& value) {
297 return *this;
298 }

operator=()

FormatSpec & simaai::neat::FormatSpec::operator= (const char * value)
inline

Assign from a parsed C string token.

Definition at line 300 of file FormatSpec.h.

300 FormatSpec& operator=(const char* value) {
301 tag = format_tag_from_string(value ? std::string(value) : std::string{});
302 return *this;
303 }

operator==()

bool simaai::neat::FormatSpec::operator== (const FormatSpec & other)
inline

Equality compares the underlying tag.

Definition at line 310 of file FormatSpec.h.

310 bool operator==(const FormatSpec& other) const {
311 return tag == other.tag;
312 }

Public Member Functions

empty()

bool simaai::neat::FormatSpec::empty ()
inline

True iff the tag is Auto (unset).

Definition at line 306 of file FormatSpec.h.

306 bool empty() const {
307 return tag == FormatTag::Auto;
308 }

str()

std::string simaai::neat::FormatSpec::str ()
inline

Canonical string form of the tag.

Definition at line 318 of file FormatSpec.h.

318 std::string str() const {
320 }

Public Member Attributes

tag

FormatTag simaai::neat::FormatSpec::tag = FormatTag::Auto

Underlying tag (defaults to unset).

Definition at line 277 of file FormatSpec.h.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.