Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
  }