00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "XrdMon/XrdMonException.hh"
00014 #include "XrdMon/XrdMonErrors.hh"
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <string.h>
00018
00019 namespace XrdMonArgParserConvert
00020 {
00021 struct Convert2String {
00022 static const char* convert(const char* s) {
00023 return s;
00024 }
00025 };
00026
00027 struct Convert2Int {
00028 static int convert(const char* s) {
00029 return atoi(s);
00030 }
00031 };
00032
00033 struct Convert2LL {
00034 static kXR_int64 convert(const char* s) {
00035 kXR_int64 x;
00036 sscanf(s, "%lld", &x);
00037 return x;
00038 }
00039 };
00040
00041 struct ConvertOnOff {
00042 static bool convert(const char* s) {
00043 if ( 0 == strcasecmp(s, "on") ) {
00044 return true;
00045 }
00046 if ( 0 == strcasecmp(s, "off") ) {
00047 return false;
00048 }
00049 string ss("Expected 'on' or 'off', found "); ss += s;
00050 throw XrdMonException(ERR_INVALIDARG, ss);
00051 return false;
00052 }
00053 };
00054 }
00055