Logo Search packages:      
Sourcecode: odyssey version File versions

bool ConfigFile::get_integerv ( const string &  section,
const string &  key,
long *  valarray,
unsigned int *  arraylen 
)

Gets an array of integer values from a configuration variable in the internal cache.

Parameters:
section The section name in the configuration file to look for the key.
key The name of the configuration variable to retrieve from the configuration section.
valarray A pointer to the location of the array where the values will be stored.
arraylen Pointer to the length of the array valarray. Only this many values will be returned.
Returns:
A boolean value indicating if the value was found or not. The value of the arraylen variable will be set to the number of elements actually returned in the array.

Definition at line 210 of file ConfigFile.cxx.

References cache.

{
      StringMap::iterator i;
      string index;
      int value_pos, next_value_pos;
      unsigned int count;

      index = section + string(".") + key;
      i = this->cache.find(index);
      if(i == this->cache.end())
            return false;

      string value = i->second;
      count = 0;
      value_pos = 0;
      while((value_pos < (int)value.length()) && (count < *arraylen)) {
            next_value_pos = value.find(',', value_pos);
            if(next_value_pos < 0) {
                  /* Last entry. Set the next position to the end of the string */
                  next_value_pos = value.length();
            }

            if(next_value_pos > value_pos) {
                  string intval = value.substr(value_pos, (next_value_pos - value_pos));
                  valarray[count] = strtol(intval.c_str(), NULL, 0);
                  count++;
            }
            value_pos = next_value_pos + 1;
      }
      *arraylen = count;

      return true;
}


Generated by  Doxygen 1.6.0   Back to index