Back to index

nordugrid-arc-nox  1.1.0~rc6
conf.h
Go to the documentation of this file.
00001 #ifndef __GM_CONF_H__
00002 #define __GM_CONF_H__
00003 
00004 #include <cstring>
00005 #include <iostream>
00006 #include <fstream>
00007 #include <string>
00008 
00009 #include <arc/XMLNode.h>
00010 #include <arc/Logger.h>
00011 
00012 extern char* config_file;
00013 
00014 /*
00015   Open/assign configuration file to provided cfile.
00016   Returns:
00017     true - success
00018     false - error
00019 */
00020 bool config_open(std::ifstream &cfile);
00021 /*
00022   Same as previous, but filename is given by 'name'.
00023 */
00024 bool config_open(std::ifstream &cfile,const std::string &name);
00025 /*
00026   Closes configuration file. Equal to cfile.close().
00027   These finctions are provided only for unified interface 
00028   and for future enhancements.
00029 */
00030 bool config_close(std::ifstream &cfile);
00031 /*
00032   Read one line of configuration file.
00033   Accepts:
00034     cfile - opened file.
00035     separator - character used to separate keywords.
00036   Returns:
00037     string containing first keyword in line.
00038     rest - rest of the string.
00039   Note: use separator=\0 to get unbroken string.
00040 */
00041 std::string config_read_line(std::istream &cfile);
00042 std::string config_read_line(std::istream &cfile,std::string &rest,char separator = ' ');
00043 /*
00044   Extract one more keyword from 'rest'.
00045   Accepts:
00046    rest - current configuration string.
00047  Returns:
00048    string containing first keyword in line.
00049    rest - rest of the string.
00050 */
00051 std::string config_next_arg(std::string &rest,char separator = ' ');
00052 
00053 typedef enum {
00054   config_file_XML,
00055   config_file_INI,
00056   config_file_unknown
00057 } config_file_type;
00058 
00059 config_file_type config_detect(std::istream& in);
00060 bool elementtobool(Arc::XMLNode pnode,const char* ename,bool& val,Arc::Logger* logger = NULL);
00061 bool elementtoint(Arc::XMLNode pnode,const char* ename,int& val,Arc::Logger* logger = NULL);
00062 bool elementtoint(Arc::XMLNode pnode,const char* ename,unsigned int& val,Arc::Logger* logger = NULL);
00063 
00064 #endif // __GM_CONF_H__