Public Member Functions | Private Attributes

val_Hostname Class Reference
[Parser for config files; validation]

#include <val.h>

Inheritance diagram for val_Hostname:
Inheritance graph
[legend]
Collaboration diagram for val_Hostname:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 val_Hostname (const string &a_name, const val_Limit a_limits, const UInt32_t a_minNumOfVal=1, const UInt32_t a_maxNumOfVal=cfg_INFINITE, const string &a_defaultStr="")
virtual ~val_Hostname ()
virtual string Validate (const string &a_strVal)
 Host name consists of multiple dot separated identifiers.

Private Attributes

UInt64_t m_multiplier
 log_CLASSID_m

Detailed Description

Definition at line 680 of file val.h.


Constructor & Destructor Documentation

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

Definition at line 918 of file val.cpp.

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

val_Hostname::~val_Hostname (  )  [virtual]

Definition at line 929 of file val.cpp.

                            {
    //Empty
}


Member Function Documentation

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

Host name consists of multiple dot separated identifiers.

Each identifier can be 63 characters long, overall length of FQDN (Fully Qualified Domain Name) must be less than or equal to 255 characters.

Valid characters for a hostname are 'A'-'Z', a-z and -. (RFC 1123)

Reimplemented from val_Value.

Definition at line 939 of file val.cpp.

References cmn_StrLowerCase(), ie_NOT_VALID, ivd_Error, and val_Value::m_name.

                                                    {

    if (a_strVal.length() > ivd_MAX_HOSTNAME_SIZE) {
        throw ivd_Error(ie_NOT_VALID,
            string("Invalid hostname. Too long. Variable: ") + m_name);
    };

    for (unsigned int i = 0, dot = 0; i < a_strVal.length(); i++) {
        if (a_strVal[i] == '.') {
            if ( (i - dot) > ivd_MAX_HOSTNAME_IDENTIFIER_SIZE ) {
                throw ivd_Error(ie_NOT_VALID,
                    string("Invalid hostname. Too long identifier name. Variable:") + m_name);
            };
            if ( (i - dot) < 1) {
                throw ivd_Error(ie_NOT_VALID,
                    string("Invalid hostname. Too short identifier name. Variable:") + m_name);
            };
            dot = i+1;
        };
        if (isalnum(a_strVal[i]) ||
            a_strVal[i] == '-' ||
            a_strVal[i] == '.' ||
            a_strVal[i] == '_' ) {// '_' is questionable! See RFC 1123.

            // Character is valid. Continue.
        }
        else {
            throw ivd_Error(ie_NOT_VALID,
                string("Invalid hostname. Invalid character. Variable: ") + m_name);
        }
    }
    string host(a_strVal);
    cmn_StrLowerCase(host);
    return host;
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from val_StrictString.

Definition at line 696 of file val.h.

Definition at line 694 of file val.h.


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