Beispiel #1
0
void indri::api::Parameters::remove( const std::string& path ) {
  parameter_value* root = _getRoot();
  size_t lastDot = path.rfind('.');
  std::string parentPath;
  std::string subpath = path;

  if( lastDot > 0 ) {
    parentPath = path.substr( 0, lastDot );
    subpath = path.substr( lastDot+1 );
  }

  parameter_value* parent = _getPath( parentPath, root );
  
  if( parent ) {
    // grab segment name and index
    std::string segment;
    int arrayIndex;
    int endOffset;

    _parseNextSegment( segment, arrayIndex, endOffset, subpath, 0 );
    parameter_value* child = parent->table[segment];

    if( child ) {
      if( child->array.size() <= 1 && arrayIndex == 0 ) {
        delete child;
        parent->table.erase( segment );
      } else if( child->array.size() > size_t(arrayIndex) ) {
        delete child->array[arrayIndex];
        child->array.erase( child->array.begin() + arrayIndex );
      }
    }
  }
}
Beispiel #2
0
indri::api::Parameters indri::api::Parameters::get( const std::string& name ) {
  assert( exists(name) );
  if( ! exists(name) )
    LEMUR_THROW( LEMUR_IO_ERROR, "Required parameter '" + name + "' was not specified." );

  parameter_value* root = _getRoot();
  parameter_value* current = _getPath(name, root);

  return indri::api::Parameters( current );
}
Beispiel #3
0
indri::api::Parameters::parameter_value* indri::api::Parameters::_getPath( const std::string& path, indri::api::Parameters::parameter_value* last, int offset ) {
  int endOffset; 
  int arrayIndex = 0;
  std::string segment;

  _parseNextSegment( segment, arrayIndex, endOffset, path, offset );
  parameter_value* next = _getSegment( segment, arrayIndex, last );

  if( next ) {
    if( endOffset == std::string::npos ) {
      // we have a value, and we're at the end of the path, so return it
      return next;
    } else {
      // we have a value, but more path left, so keep going
      return _getPath( path, next, endOffset+1 );
    }
  } else {
    return 0;
  }
}
Beispiel #4
0
void Connection::open()
{
	connect(_getPath());
}
Beispiel #5
0
bool indri::api::Parameters::exists( const std::string& name ) {
  parameter_value* root = _getRoot();
  parameter_value* value = _getPath( name, root );

  return value ? true : false;
}