Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Omniifr::IdentifierUtil Class Reference

Utility class containing useful methods for manipulating IDL identifiers. More...

#include <IdentifierUtil.h>

List of all members.

Public Types

enum  Match { equalMatch, equivalentMatch, noMatch }

Static Public Member Functions

static Match compare (const char *n1, const char *n2)
static void checkInvalid (const char *name)
 Generates a BAD_PARAM exception if name is not a valid IDL identifier.


Detailed Description

Utility class containing useful methods for manipulating IDL identifiers.

Definition at line 45 of file IdentifierUtil.h.


Member Enumeration Documentation

enum Omniifr::IdentifierUtil::Match
 

Enumeration values:
equalMatch  Identifiers match exactly.
equivalentMatch  Identifiers only match case-insensitively.
noMatch  Identifiers do not match, even case-insensitively.

Definition at line 49 of file IdentifierUtil.h.

00049             {
00050     equalMatch,      
00051     equivalentMatch, 
00052     noMatch          
00053   };


Member Function Documentation

static void Omniifr::IdentifierUtil::checkInvalid const char *  name  )  [inline, static]
 

Generates a BAD_PARAM exception if name is not a valid IDL identifier.

Valid identifiers match this Regex: [a-zA-Z][_a-zA-Z0-9]*

Definition at line 70 of file IdentifierUtil.h.

References IFELSE_OMNIORB4.

00071   {
00072     // Should not be testing NULL pointers.
00073     assert(name);
00074 
00075     bool valid =bool( name[0] ); // string not empty
00076 
00077     if(valid)
00078     {
00079       for(int i=0; name[i]; ++i)
00080       {
00081         char c =tolower(name[i]);
00082         if( ('a'<=c && c<='z') ||
00083             (i>0 &&
00084               ( ('0'<=c && c<='9') ||
00085                 c=='_'
00086           ) ) )
00087         {
00088           continue; // still valid
00089         }
00090         valid=false;
00091         break;
00092       }
00093     }
00094 
00095     if(!valid)
00096     {
00097       throw CORBA::BAD_PARAM(
00098         IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidName,15),
00099         CORBA::COMPLETED_NO
00100       );
00101     }
00102   }

static Match Omniifr::IdentifierUtil::compare const char *  n1,
const char *  n2
[inline, static]
 

Definition at line 55 of file IdentifierUtil.h.

References equalMatch, equivalentMatch, and noMatch.

00056   {
00057     if(!n1 || !n2)
00058         return noMatch;
00059     else if(0==strcmp(n1,n2))
00060         return equalMatch;
00061     else if(0==strcasecmp(n1,n2))
00062         return equivalentMatch;
00063     else
00064         return noMatch;
00065   }


The documentation for this class was generated from the following file:
Generated on Fri Mar 4 13:04:01 2005 for OmniIFR by  doxygen 1.4.1