Back to index

nordugrid-arc-nox  1.1.0~rc6
Enumerations | Functions | Variables
conf.h File Reference
#include <cstring>
#include <iostream>
#include <fstream>
#include <string>
#include <arc/XMLNode.h>
#include <arc/Logger.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  config_file_type { config_file_XML, config_file_INI, config_file_unknown }

Functions

bool config_open (std::ifstream &cfile)
bool config_open (std::ifstream &cfile, const std::string &name)
bool config_close (std::ifstream &cfile)
std::string config_read_line (std::istream &cfile)
std::string config_read_line (std::istream &cfile, std::string &rest, char separator= ' ')
std::string config_next_arg (std::string &rest, char separator= ' ')
config_file_type config_detect (std::istream &in)
bool elementtobool (Arc::XMLNode pnode, const char *ename, bool &val, Arc::Logger *logger=NULL)
bool elementtoint (Arc::XMLNode pnode, const char *ename, int &val, Arc::Logger *logger=NULL)
bool elementtoint (Arc::XMLNode pnode, const char *ename, unsigned int &val, Arc::Logger *logger=NULL)

Variables

char * config_file

Enumeration Type Documentation

Enumerator:
config_file_XML 
config_file_INI 
config_file_unknown 

Definition at line 53 of file conf.h.


Function Documentation

bool config_close ( std::ifstream &  cfile)

Definition at line 39 of file conf.cpp.

                                      {
  if(cfile.is_open()) cfile.close();
  return true;
}

Here is the caller graph for this function:

config_file_type config_detect ( std::istream &  in)

Definition at line 74 of file conf.cpp.

                                               {
  char inchar;
  while(in.good()) {
    inchar = (char)(in.get());
    if(isspace(inchar)) continue;
    if(inchar == '<') {
      // XML starts from < even if it is comment
      in.putback(inchar);
      return config_file_XML;
    };
    if((inchar == '#') || (inchar = '[')) {
      // INI file starts from comment or section
      in.putback(inchar);
      return config_file_INI;
    };
  };
  in.putback(inchar);
  return config_file_unknown;
}

Here is the caller graph for this function:

std::string config_next_arg ( std::string &  rest,
char  separator = ' ' 
)

Definition at line 66 of file conf.cpp.

                                                          {
  int n;
  std::string arg;
  n=input_escaped_string(rest.c_str(),arg,separator);
  rest=rest.substr(n);
  return arg;
}    

Here is the call graph for this function:

Here is the caller graph for this function:

bool config_open ( std::ifstream &  cfile)

Definition at line 30 of file conf.cpp.

                                     {
  return config_open(cfile,nordugrid_config_loc());
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool config_open ( std::ifstream &  cfile,
const std::string &  name 
)

Definition at line 34 of file conf.cpp.

                                                           {
  cfile.open(name.c_str(),std::ifstream::in);
  return cfile.is_open();
}
std::string config_read_line ( std::istream &  cfile)

Definition at line 49 of file conf.cpp.

                                              {
  std::string rest;
  for(;;) {
    if(cfile.eof()) { rest=""; return rest; };
    {
      char buf[4096];
      istream_readline(cfile,buf,sizeof(buf));
      rest=buf;
    };
    std::string::size_type n=rest.find_first_not_of(" \t");
    if(n == std::string::npos) continue; /* empty string - skip */
    if(rest[n] == '#') continue; /* comment - skip */
    break;
  };
  return rest;
}
std::string config_read_line ( std::istream &  cfile,
std::string &  rest,
char  separator = ' ' 
)

Definition at line 44 of file conf.cpp.

                                                                             {
  rest = config_read_line(cfile);
  return config_next_arg(rest,separator);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool elementtobool ( Arc::XMLNode  pnode,
const char *  ename,
bool &  val,
Arc::Logger logger = NULL 
)

Definition at line 95 of file conf.cpp.

                                                                                   {
  std::string v = ename?pnode[ename]:pnode;
  if(v.empty()) return true; // default
  if((v == "true") || (v == "1")) {
    val=true;
    return true;
  };
  if((v == "false") || (v == "0")) {
    val=false;
    return true;
  };
  if(logger && ename) logger->msg(Arc::ERROR,"wrong boolean in %s: %s",ename,v.c_str());
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool elementtoint ( Arc::XMLNode  pnode,
const char *  ename,
int &  val,
Arc::Logger logger = NULL 
)

Definition at line 118 of file conf.cpp.

                                                                                 {
  std::string v = ename?pnode[ename]:pnode;
  if(v.empty()) return true; // default
  if(Arc::stringto(v,val)) return true;
  if(logger && ename) logger->msg(Arc::ERROR,"wrong number in %s: %s",ename,v.c_str());
  return false;
}

Here is the call graph for this function:

bool elementtoint ( Arc::XMLNode  pnode,
const char *  ename,
unsigned int &  val,
Arc::Logger logger = NULL 
)

Definition at line 110 of file conf.cpp.

                                                                                          {
  std::string v = ename?pnode[ename]:pnode;
  if(v.empty()) return true; // default
  if(Arc::stringto(v,val)) return true;
  if(logger && ename) logger->msg(Arc::ERROR,"wrong number in %s: %s",ename,v.c_str());
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* config_file