예제 #1
0
  ConfigParser::EntryList* ConfigParser::get_section(std::string prefix) {
    ConfigParser::EntryList* list = new ConfigParser::EntryList(0);

    ConfigParser::ConfigMap::iterator i = variables.begin();
    while(i != variables.end()) {
      if(i->second->in_section(prefix)) {
        list->push_back(i->second);
      }
      i++;
    }

    return list;
  }
예제 #2
0
  Object* System::vm_get_config_section(STATE, String* section) {
    ConfigParser::EntryList* list;

    list = state->user_config->get_section(section->byte_address());

    Array* ary = Array::create(state, list->size());
    for(size_t i = 0; i < list->size(); i++) {
      String* var = String::create(state, list->at(i)->variable.c_str());
      String* val = String::create(state, list->at(i)->value.c_str());

      ary->set(state, i, Tuple::from(state, 2, var, val));
    }

    return ary;
  }
예제 #3
0
  void test_get_section() {
    std::istringstream stream;

    stream.str("rbx.test.blah = 8\nrbx.test.foo = fun\nrbx.crazy = true");

    ConfigParser cfg;

    cfg.import_stream(stream);

    ConfigParser::EntryList* l = cfg.get_section("rbx.test");

    TS_ASSERT_EQUALS(l->size(), (unsigned int)2);
    TS_ASSERT_EQUALS(l->at(0)->variable, "rbx.test.blah");
    TS_ASSERT_EQUALS(l->at(1)->variable, "rbx.test.foo");

    delete l;
  }