Public Member Functions | Private Attributes

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.

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

Detailed Description

Definition at line 645 of file val.h.


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 827 of file val.cpp.

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

val_Percentage::~val_Percentage (  )  [virtual]

Definition at line 838 of file val.cpp.

                                {
    //Empty
}


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 842 of file val.cpp.

References ie_NOT_VALID, ivd_Error, and val_Value::m_name.

                                                      {

    if (a_strVal.length() < 2) {
        ostringstream sstr;
        sstr
            << "Invalid percentage format. String too short. Variable: " << m_name;

        throw ivd_Error(ie_NOT_VALID, sstr.str());
    };

    char lastChar = a_strVal[a_strVal.length() - 1];
    switch (lastChar) {
        case '%': // % sign detected. OK.
            break;
        default:
            {
                ostringstream sstr;
                sstr
                    << "Invalid percentage format. Expected %. Variable: " << m_name
                    << " = " << a_strVal;

                throw ivd_Error(ie_NOT_VALID, sstr.str());
                break;
            }
    }
    return a_strVal.substr(0, a_strVal.length()-1);
}


Member Data Documentation

Reimplemented from val_Integer.

Definition at line 658 of file val.h.


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