00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OMNIIFR__IDENTIFIERUTIL_H
00024 #define OMNIIFR__IDENTIFIERUTIL_H
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include "config.h"
00028 #endif
00029
00030 #ifdef HAVE_OMNIORB3
00031 # include <omniORB3/CORBA.h>
00032 #endif
00033
00034 #ifdef HAVE_OMNIORB4
00035 # include <omniORB4/CORBA.h>
00036 #endif
00037
00038 #include <ctype.h>
00039 #include <string.h>
00040
00041 namespace Omniifr {
00042
00045 class IdentifierUtil
00046 {
00047 public:
00048
00049 enum Match{
00050 equalMatch,
00051 equivalentMatch,
00052 noMatch
00053 };
00054
00055 inline static Match compare(const char* n1, const char* n2)
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 }
00066
00070 inline static void checkInvalid(const char* name)
00071 {
00072
00073 assert(name);
00074
00075 bool valid =bool( name[0] );
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;
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 }
00103 };
00104
00105 }
00106
00107 #endif // OMNIIFR__IDENTIFIERUTIL_H