val_Percentage Class Reference
[Parser for config files; validation]

#include <val.h>

Inheritance diagram for val_Percentage:

Inheritance graph
[legend]
Collaboration diagram for val_Percentage:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 631 of file val.h.


Public Member Functions

 val_Percentage (const string &a_name, const val_Limit a_limits, const UInt32_t a_minNumOfVal=1, const UInt64_t a_maxNumOfVal=cfg_INFINITE, const string &a_defaultStr="")
virtual ~val_Percentage ()
virtual string Validate (const string &a_strVal)

Private Attributes

 log_CLASSID_m

Constructor & Destructor Documentation

val_Percentage::val_Percentage ( const string &  a_name,
const val_Limit  a_limits,
const UInt32_t  a_minNumOfVal = 1,
const UInt64_t  a_maxNumOfVal = cfg_INFINITE,
const string &  a_defaultStr = "" 
)

Definition at line 813 of file val.cpp.

00819   : val_Integer(a_name, a_limits, a_minNumOfVal, a_maxNumOfVal,  a_defaultStr ) {
00820     // Empty
00821 }

val_Percentage::~val_Percentage (  )  [virtual]

Definition at line 824 of file val.cpp.

00824                                 {
00825     //Empty
00826 }


Member Function Documentation

string val_Percentage::Validate ( const string &  a_strVal  )  [virtual]

Warning:
Validate() must return a string which is then used in Assign(). By default the argument is just returned.

Reimplemented from val_Value.

Definition at line 828 of file val.cpp.

References ie_NOT_VALID, ivd_Error, and val_Value::m_name.

00828                                                       {
00829 
00830     if (a_strVal.length() < 2) {
00831         ostringstream sstr;
00832         sstr
00833             << "Invalid percentage format. String too short. Variable: " << m_name;
00834 
00835         throw ivd_Error(ie_NOT_VALID, sstr.str());
00836     };
00837 
00838     char lastChar = a_strVal[a_strVal.length() - 1];
00839     switch (lastChar) {
00840         case '%': // % sign detected. OK.
00841             break;
00842         default:
00843             {
00844                 ostringstream sstr;
00845                 sstr
00846                     << "Invalid percentage format. Expected %. Variable: " << m_name
00847                     << " = " << a_strVal;
00848 
00849                 throw ivd_Error(ie_NOT_VALID, sstr.str());
00850                 break;
00851             }
00852     }
00853     return a_strVal.substr(0, a_strVal.length()-1);
00854 }


Member Data Documentation

Reimplemented from val_Integer.

Definition at line 644 of file val.h.


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

Generated on Mon Feb 27 19:51:53 2012 for OPENARCHIVE by  doxygen 1.5.6