nis-util  1.0.D108
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
configuration_item Class Reference

#include <item.h>

Inheritance diagram for configuration_item:
configuration_item_boolean configuration_item_integer configuration_item_string

Public Types

enum  level_t {
  level_builtin, level_etc_nis_util_conf, level_home_nis_util_rc, level_nis_util_env,
  level_nis_util_prog_env, level_command_line_file, level_command_line_option
}
typedef boost::shared_ptr
< configuration_item
pointer

Public Member Functions

virtual ~configuration_item ()
virtual rcstring get_string_value (void) const =0
virtual bool get_bool_value (void) const =0
virtual long get_long_value (void) const =0
const source_locationget_source_location (void) const
level_t get_level (void) const
rcstring get_name (void) const
void print (void) const

Static Public Member Functions

static const char * level_name (level_t value)

Protected Member Functions

 configuration_item (const source_location &locn, level_t level, const rcstring &name)

Private Attributes

source_location locn
level_t level
rcstring name

Detailed Description

The configuration_item class is used to represent a single configuration configuration_item's setting. Once created, it can't be modified, updates are accomplished by replacemnt.

Definition at line 34 of file item.h.


Member Typedef Documentation

typedef boost::shared_ptr<configuration_item> configuration_item::pointer

Definition at line 37 of file item.h.


Member Enumeration Documentation

The level_t type describes the source of a configuration setting, and also acts as a precedence indicatorm higher values have higher precedence.

Note:
The order in which these configuration sources are parsed is not relevant, even the last two.
If you change this enum, you must also change the man/man5/uns-util-conf.5 man page.
Enumerator:
level_builtin 

The configuration item's hard coded default. Usually conservative, maximum informative-ness.

level_etc_nis_util_conf 

The configuration item is from the /etc/nis-util.conf file.

level_home_nis_util_rc 

The configuration item is from the $HOME/.nis-util.rc file.

level_nis_util_env 

The configuration item is from the $NIS_UTIL environment variable. This is formatted identically to the file format, including newlines, but in a string.

level_nis_util_prog_env 

The configuration item is from the util-specific environment variable. This is formatted identically to the file format, including newlines, but in a string.

The nameof the environmae variable us determined using the following code:

 rcstring name =
     rcstring(explain_program_name_get()).upcase().identifier();

That is: take the name of the running program, make it all upper case, and recplace any non-identifier characters with nul. For example "nis-util-passwd" becomes "NIS_UTIL_PASSWD".

level_command_line_file 

A configuration file specified on the command line, using the --configuration=filename command line option.

level_command_line_option 

A command line option, as it relates to a specific item, usually in the [global] section.

Definition at line 57 of file item.h.


Constructor & Destructor Documentation

The destructor.

Definition at line 23 of file item.cc.

configuration_item::configuration_item ( const source_location locn,
level_t  level,
const rcstring name 
) [protected]

The constructor. For use by derived classes only.

Parameters:
locnThe source file location of this configuration item.
levelThe precedence level of this configuration item.
nameThe name of this configuration item.

Definition at line 28 of file item.cc.


Member Function Documentation

virtual bool configuration_item::get_bool_value ( void  ) const [pure virtual]

The get_string_value method is used to obtain the value of this configuration item, as a boolean.

Implemented in configuration_item_boolean, configuration_item_integer, and configuration_item_string.

level_t configuration_item::get_level ( void  ) const [inline]

The get_level method is used to obtain the current precedence level of this configuration item. New settings will only "take" if they are of a higher precedence than this.

Definition at line 149 of file item.h.

virtual long configuration_item::get_long_value ( void  ) const [pure virtual]

The get_string_value method is used to obtain the value of this configuration item, as an integer.

Implemented in configuration_item_boolean, configuration_item_integer, and configuration_item_string.

rcstring configuration_item::get_name ( void  ) const [inline]

The get_name method is used to obtain the name of this configuration item, local to the section it is within.

Definition at line 155 of file item.h.

const source_location& configuration_item::get_source_location ( void  ) const [inline]

The get_source_location method is used to obtain the source file location of the setting. Used for better error messages.

Definition at line 142 of file item.h.

virtual rcstring configuration_item::get_string_value ( void  ) const [pure virtual]

The get_string_value method is used to obtain the value of this configuration item, as a string.

Implemented in configuration_item_boolean, configuration_item_integer, and configuration_item_string.

const char * configuration_item::level_name ( level_t  value) [static]

The level_name class method is used to obtain a human readable string representation of a precedence level.

Definition at line 41 of file item.cc.

void configuration_item::print ( void  ) const

The print method is used to print this configuration item on the standard output. This is mostly useful for debugging.

Definition at line 25 of file print.cc.


Field Documentation

The level instance variable is used to remember the current precedence level of this configuration item. New settings will only "take" if they are higher than this.

Definition at line 190 of file item.h.

The locn instance variable is used to remember the source code location of this configuration item.

Definition at line 183 of file item.h.

The name instance variable is used to remember the name of this configuration item, local to the section it is within.

Definition at line 196 of file item.h.


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