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

XrdMonArgParserConvert.hh

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*                                                                           */
00003 /*                        XrdMonArgParserConvert.hh                          */
00004 /*                                                                           */
00005 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
00006 /*                            All Rights Reserved                            */
00007 /*       Produced by Jacek Becla for Stanford University under contract      */
00008 /*              DE-AC02-76SF00515 with the Department of Energy              */
00009 /*****************************************************************************/
00010 
00011 // $Id$
00012 
00013 #include "XrdMon/XrdMonException.hh"
00014 #include "XrdMon/XrdMonErrors.hh"
00015 #include <stdio.h>
00016 #include <stdlib.h> /* atoi */
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 

Generated on Sun Nov 6 13:39:23 2011 for xrootd by  doxygen 1.3.9.1