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.


Detailed Description

Definition at line 666 of file val.h.


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

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

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

val_Hostname::~val_Hostname (  )  [virtual]

Definition at line 915 of file val.cpp.

00915                             {
00916     //Empty
00917 }


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

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

00925                                                     {
00926 
00927     if (a_strVal.length() > ivd_MAX_HOSTNAME_SIZE) {
00928         throw ivd_Error(ie_NOT_VALID,
00929             string("Invalid hostname. Too long. Variable: ") + m_name);
00930     };
00931 
00932     for (unsigned int i = 0, dot = 0; i < a_strVal.length(); i++) {
00933         if (a_strVal[i] == '.') {
00934             if ( (i - dot) > ivd_MAX_HOSTNAME_IDENTIFIER_SIZE ) {
00935                 throw ivd_Error(ie_NOT_VALID,
00936                     string("Invalid hostname. Too long identifier name. Variable:") + m_name);
00937             };
00938             if ( (i - dot) < 1) {
00939                 throw ivd_Error(ie_NOT_VALID,
00940                     string("Invalid hostname. Too short identifier name. Variable:") + m_name);
00941             };
00942             dot = i+1;
00943         };
00944         if (isalnum(a_strVal[i]) ||
00945             a_strVal[i] == '-' ||
00946             a_strVal[i] == '.' ||
00947             a_strVal[i] == '_' ) {// '_' is questionable! See RFC 1123.
00948 
00949             // Character is valid. Continue.
00950         }
00951         else {
00952             throw ivd_Error(ie_NOT_VALID,
00953                 string("Invalid hostname. Invalid character. Variable: ") + m_name);
00954         }
00955     }
00956     string host(a_strVal);
00957     cmn_StrLowerCase(host);
00958     return host;
00959 }

Here is the call graph for this function:


Member Data Documentation

Definition at line 680 of file val.h.

Reimplemented from val_StrictString.

Definition at line 682 of file val.h.


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

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