Rosetta
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
utility::tag::Tag Class Reference

#include <Tag.hh>

Inheritance diagram for utility::tag::Tag:
Inheritance graph
[legend]

Public Types

typedef std::map< std::string, std::string > options_t
 
typedef utility::vector0< TagCOPtags_t
 

Public Member Functions

 ~Tag () override
 Automatically generated virtual destructor for class deriving directly from VirtualBase. More...
 
 Tag ()
 
TagCOP get_self_ptr () const
 self pointers More...
 
TagOP get_self_ptr ()
 
TagCAP get_self_weak_ptr () const
 
TagAP get_self_weak_ptr ()
 
void clear ()
 
size_t size () const
 
void setName (std::string const &name)
 
std::string const & getName () const
 
TagCAP const & getParent () const
 
void addTag (TagOP tag)
 
utility::vector0< TagCOP > const & getTags () const
 
utility::vector0< TagCOP > const & getTags (std::string const &name) const
 
TagCOP const & getTag (std::string const &name) const
 
bool hasTag (std::string const &name) const
 Does the Tag have a specific sub-tag (branch) within (such as a MoveMap, etc.)? More...
 
bool hasOption (std::string const &key) const
 Does the Tag have a specific option? More...
 
template<class T >
void setOption (std::string const &key, T const &value)
 
void setAccessed (std::string const &key) const
 Set the 'accessed' annotation of this option, without bothering to get the value. Used to prevent no-longer relevant options from crashing the XML parsing. More...
 
template<class T >
T getOption (std::string const &key, T const &t_default) const
 Retrieve an option from the Tag with the given key name, using the provided default value (t_default) if the option is not present in the tag. More...
 
template<class T >
T getOption (std::string const &, int const) const =delete
 Variant that will only be defined for Sizes. More...
 
template<class T >
T getOption (std::string const &key, char const *default_as_string_literal) const =delete
 Variant for the case in which the developer has mistakenly provided a string literal instead of a value of type T. For anything but a boolean or a string type, this produces a compilation error. More...
 
template<class T >
T getOption (std::string const &key) const
 Retrieve an option from the Tag with the given key name. More...
 
options_t const & getOptions () const
 
void setOptions (options_t const &options)
 
void read (std::istream &in)
 
void read (std::string const &tag_string)
 
void write (std::ostream &out, int num_tabs=0) const
 
std::string to_string (int num_tabs=0) const
 returns the string that would be written by write() More...
 
TagCOP const & operator[] (std::string const &key) const
 
Tagoperator= (Tag const &other)
 
void reset_accessed_options () const
 Recursively reset that accessed_options_ variable so that a re-parsing of the tag can identify options that have been given but that have not been read. More...
 
void die_for_unaccessed_options () const
 
void die_for_unaccessed_options_recursively () const
 
TagOP clone () const
 
void set_quote_options (bool const quote_options_val)
 if true, options will be quoted when the tag is outputted if false, options will be left as-is (default) More...
 
template<>
bool getOption (std::string const &key, bool const &t_default) const
 
template<>
bool getOption (std::string const &key, char const *default_as_string_literal) const
 This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false. More...
 
template<>
bool getOption (std::string const &key) const
 
template<>
AutoBool getOption (std::string const &key, AutoBool const &t_default) const
 
template<>
AutoBool getOption (std::string const &key, char const *default_as_string_literal) const
 This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false. More...
 
template<>
AutoBool getOption (std::string const &key) const
 
template<>
int getOption (std::string const &key, int const default_int) const
 Special-casing for signed ints. More...
 
template<>
int64_t getOption (std::string const &key, int const default_int) const
 Special-casing for int64_t. More...
 
template<>
bool getOption (std::string const &key, bool const &t_default) const
 This is explicit specialization for boolean values to allow for use of "true" "false" etc. in addition to 1 and 0. More...
 
template<>
bool getOption (std::string const &key, char const *default_as_string_literal) const
 This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false. More...
 
template<>
bool getOption (std::string const &key) const
 
template<>
AutoBool getOption (std::string const &key, AutoBool const &t_default) const
 
template<>
AutoBool getOption (std::string const &key, char const *default_as_string_literal) const
 This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false. More...
 
template<>
AutoBool getOption (std::string const &key) const
 
template<>
std::string getOption (std::string const &key, char const *default_as_string_literal) const
 Special-casing the string literal version for string options. In this case, there shouldn't be an error thrown. A string literal should be allowed to set the default value for a string. More...
 
template<>
platform::Size getOption (std::string const &key, int const default_int) const
 Special-casing to ensure that 0 gets interpreted as Size(0) rather than nullptr. More...
 
template<>
int getOption (std::string const &key, int const default_int) const
 Special-casing for signed ints. More...
 
template<>
int64_t getOption (std::string const &key, int const default_int) const
 Special-casing for int64_t. More...
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Static Public Member Functions

static TagOP create (std::istream &in)
 
static TagOP create (std::string const &instring)
 

Private Attributes

std::string name_
 
options_t mOptions_
 
options_t accessed_options_
 
tags_t vTags_
 
std::map< std::string, tags_tmvTags_
 
TagCAP parentTag_
 
bool quote_options_
 if true, options will be quoted when the tag is outputted (default) if false, options will be left without quotes More...
 

Static Private Attributes

static utility::vector0< TagCOP > const vEmpty_
 

Member Typedef Documentation

◆ options_t

typedef std::map<std::string, std::string > utility::tag::Tag::options_t

◆ tags_t

Constructor & Destructor Documentation

◆ ~Tag()

utility::tag::Tag::~Tag ( )
overridedefault

Automatically generated virtual destructor for class deriving directly from VirtualBase.

Auto-generated virtual destructor

◆ Tag()

utility::tag::Tag::Tag ( )

Referenced by operator=().

Member Function Documentation

◆ addTag()

void utility::tag::Tag::addTag ( TagOP  tag)

References get_self_weak_ptr(), mvTags_, tag, and vTags_.

Referenced by operator=().

◆ clear()

void utility::tag::Tag::clear ( )

◆ clone()

TagOP utility::tag::Tag::clone ( ) const

◆ create() [1/2]

TagOP utility::tag::Tag::create ( std::istream &  in)
static

◆ create() [2/2]

TagOP utility::tag::Tag::create ( std::string const &  instring)
static

◆ die_for_unaccessed_options()

void utility::tag::Tag::die_for_unaccessed_options ( ) const

◆ die_for_unaccessed_options_recursively()

void utility::tag::Tag::die_for_unaccessed_options_recursively ( ) const

◆ get_self_ptr() [1/2]

TagOP utility::tag::Tag::get_self_ptr ( )
inline

◆ get_self_ptr() [2/2]

TagCOP utility::tag::Tag::get_self_ptr ( ) const
inline

self pointers

◆ get_self_weak_ptr() [1/2]

TagAP utility::tag::Tag::get_self_weak_ptr ( )
inline

◆ get_self_weak_ptr() [2/2]

TagCAP utility::tag::Tag::get_self_weak_ptr ( ) const
inline

Referenced by addTag().

◆ getName()

std::string const& utility::tag::Tag::getName ( ) const
inline

References name_.

Referenced by add_protocols(), getOption(), and reverse_convert().

◆ getOption() [1/22]

template<class T >
T utility::tag::Tag::getOption ( std::string const &  ,
int const   
) const
delete

Variant that will only be defined for Sizes.

Note
Older clang compilers have trouble with the general case being deleted and then specialized cases being defined, even though this is supposed to be supported by the cxx11 standard.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References subloop_histogram::key, pyrosetta.distributed.cluster.exceptions::T, and utility_exit_with_message.

◆ getOption() [2/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key) const
Exceptions
Throwsa utility::excn::EXCN_Msg_Exception if none of the accepted boolean strings is provided.

References accessed_options_, CREATE_EXCEPTION, getName(), create_a3b_hbs::i, utility::is_false_string(), utility::is_true_string(), subloop_histogram::key, and mOptions_.

◆ getOption() [3/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key) const
Exceptions
Throwsa utility::excn::EXCN_Msg_Exception if none of the accepted boolean strings is provided.

References accessed_options_, utility::tag::Auto, CREATE_EXCEPTION, utility::tag::False, getName(), create_a3b_hbs::i, utility::is_false_string(), utility::is_true_string(), subloop_histogram::key, mOptions_, utility::tag::True, and utility::upper().

◆ getOption() [4/22]

template<class T >
T utility::tag::Tag::getOption ( std::string const &  key) const
inline

Retrieve an option from the Tag with the given key name.

Exceptions
Throwsa utility::excn::EXCN_Msg_Exception if the an option with the given key is not present, or if the boost::lexical_cast fails to convert the input type as requested.

References accessed_options_, CREATE_EXCEPTION, create_a3b_hbs::i, subloop_histogram::key, mOptions_, and pyrosetta.distributed.cluster.exceptions::T.

◆ getOption() [5/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key) const

◆ getOption() [6/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key) const

◆ getOption() [7/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key,
AutoBool const &  t_default 
) const

◆ getOption() [8/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key,
AutoBool const &  t_default 
) const

◆ getOption() [9/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key,
bool const &  t_default 
) const

This is explicit specialization for boolean values to allow for use of "true" "false" etc. in addition to 1 and 0

Exceptions
Throwsa utility::excn::EXCN_Msg_Exception if the option is proviced, but the string that's given is not a valid true/false string (either "true", "false", "1" or "0").

References accessed_options_, CREATE_EXCEPTION, create_a3b_hbs::i, utility::is_false_string(), utility::is_true_string(), subloop_histogram::key, and mOptions_.

◆ getOption() [10/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key,
bool const &  t_default 
) const

This is explicit specialization for boolean values to allow for use of "true" "false" etc. in addition to 1 and 0.

◆ getOption() [11/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const

This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false.

References CREATE_EXCEPTION, create_a3b_hbs::i, utility::is_false_string(), utility::is_true_string(), subloop_histogram::key, mOptions_, and runtime_assert_string_msg.

◆ getOption() [12/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const

This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false.

References utility::tag::Auto, CREATE_EXCEPTION, utility::tag::False, create_a3b_hbs::i, utility::is_false_string(), utility::is_true_string(), subloop_histogram::key, mOptions_, runtime_assert_string_msg, utility::tag::True, and utility::upper().

◆ getOption() [13/22]

template<>
bool utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const

This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [14/22]

template<>
AutoBool utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const

This is for the variant in which someone has specified a default using "true" instead of true, or "false" instead of false.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [15/22]

template<>
std::string utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const

Special-casing the string literal version for string options. In this case, there shouldn't be an error thrown. A string literal should be allowed to set the default value for a string.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [16/22]

template<class T >
T utility::tag::Tag::getOption ( std::string const &  key,
char const *  default_as_string_literal 
) const
delete

Variant for the case in which the developer has mistakenly provided a string literal instead of a value of type T. For anything but a boolean or a string type, this produces a compilation error.

Note
Older clang compilers have trouble with the general case being deleted and then specialized cases being defined, even though this is supposed to be supported by the cxx11 standard.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [17/22]

template<>
int utility::tag::Tag::getOption ( std::string const &  key,
int const  default_int 
) const

◆ getOption() [18/22]

template<>
int64_t utility::tag::Tag::getOption ( std::string const &  key,
int const  default_int 
) const

Special-casing for int64_t.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

References subloop_histogram::key.

◆ getOption() [19/22]

template<>
platform::Size utility::tag::Tag::getOption ( std::string const &  key,
int const  default_int 
) const

Special-casing to ensure that 0 gets interpreted as Size(0) rather than nullptr.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [20/22]

template<>
int utility::tag::Tag::getOption ( std::string const &  key,
int const  default_int 
) const

Special-casing for signed ints.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [21/22]

template<>
int64_t utility::tag::Tag::getOption ( std::string const &  key,
int const  default_int 
) const

Special-casing for int64_t.

Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org).

◆ getOption() [22/22]

template<class T >
T utility::tag::Tag::getOption ( std::string const &  key,
T const &  t_default 
) const
inline

Retrieve an option from the Tag with the given key name, using the provided default value (t_default) if the option is not present in the tag.

Exceptions
Throwsa utility::excn::EXCN_Msg_Exception if the boost::lexical_cast fails to convert the input type as requested.

References accessed_options_, CREATE_EXCEPTION, create_a3b_hbs::i, subloop_histogram::key, and mOptions_.

◆ getOptions()

Tag::options_t const & utility::tag::Tag::getOptions ( ) const

References mOptions_.

◆ getParent()

TagCAP const& utility::tag::Tag::getParent ( ) const
inline

References parentTag_.

◆ getTag()

TagCOP const & utility::tag::Tag::getTag ( std::string const &  name) const

◆ getTags() [1/2]

utility::vector0< TagCOP > const & utility::tag::Tag::getTags ( ) const

References vTags_.

Referenced by add_protocols(), getTag(), hasTag(), and reverse_convert().

◆ getTags() [2/2]

utility::vector0< TagCOP > const & utility::tag::Tag::getTags ( std::string const &  name) const

References create_a3b_hbs::i, mvTags_, and vEmpty_.

◆ hasOption()

bool utility::tag::Tag::hasOption ( std::string const &  key) const

Does the Tag have a specific option?

References create_a3b_hbs::i, subloop_histogram::key, and mOptions_.

◆ hasTag()

bool utility::tag::Tag::hasTag ( std::string const &  name) const

Does the Tag have a specific sub-tag (branch) within (such as a MoveMap, etc.)?

References getTags().

◆ operator=()

Tag & utility::tag::Tag::operator= ( Tag const &  other)

◆ operator[]()

TagCOP const & utility::tag::Tag::operator[] ( std::string const &  key) const

References getTag(), and subloop_histogram::key.

◆ read() [1/2]

void utility::tag::Tag::read ( std::istream &  in)

References ObjexxFCL::read(), and str().

◆ read() [2/2]

void utility::tag::Tag::read ( std::string const &  tag_string)

◆ reset_accessed_options()

void utility::tag::Tag::reset_accessed_options ( ) const

Recursively reset that accessed_options_ variable so that a re-parsing of the tag can identify options that have been given but that have not been read.

References accessed_options_, and vTags_.

◆ set_quote_options()

void utility::tag::Tag::set_quote_options ( bool const  quote_options_val)

if true, options will be quoted when the tag is outputted if false, options will be left as-is (default)

Parameters
[in]quote_options_valWhether or not option values should be quoted. Default=false
[in]quote_options_valWhether or not option values should be quoted. Default=true

◆ setAccessed()

void utility::tag::Tag::setAccessed ( std::string const &  key) const
inline

Set the 'accessed' annotation of this option, without bothering to get the value. Used to prevent no-longer relevant options from crashing the XML parsing.

References accessed_options_, and subloop_histogram::key.

◆ setName()

void utility::tag::Tag::setName ( std::string const &  name)

References name_.

◆ setOption()

template<class T >
void utility::tag::Tag::setOption ( std::string const &  key,
T const &  value 
)
inline

◆ setOptions()

void utility::tag::Tag::setOptions ( options_t const &  options)

References accessed_options_, mOptions_, and options.

◆ size()

size_t utility::tag::Tag::size ( ) const

References vTags_.

◆ to_string()

std::string utility::tag::Tag::to_string ( int  num_tabs = 0) const

returns the string that would be written by write()

References challenge::ss, and write().

◆ write()

void utility::tag::Tag::write ( std::ostream &  out,
int  num_tabs = 0 
) const

References mOptions_, name_, quote_options_, tag, and vTags_.

Referenced by to_string().

Member Data Documentation

◆ accessed_options_

options_t utility::tag::Tag::accessed_options_
mutableprivate

◆ mOptions_

options_t utility::tag::Tag::mOptions_
private

◆ mvTags_

std::map<std::string,tags_t> utility::tag::Tag::mvTags_
private

Referenced by addTag(), clear(), and getTags().

◆ name_

std::string utility::tag::Tag::name_
private

◆ parentTag_

TagCAP utility::tag::Tag::parentTag_
private

Referenced by clear(), and getParent().

◆ quote_options_

bool utility::tag::Tag::quote_options_
private

if true, options will be quoted when the tag is outputted (default) if false, options will be left without quotes

Referenced by write().

◆ vEmpty_

utility::vector0< TagCOP > const utility::tag::Tag::vEmpty_
staticprivate

Referenced by getTags().

◆ vTags_

tags_t utility::tag::Tag::vTags_
private

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