示例#1
0
void DOMParsePerson()
{
   PersonList personlist;
   gROOT->ProcessLine(".O 0");
   TString dir = gSystem->DirName(__FILE__);
   if (personlist.ParseFile(dir+"/person.xml") == 0)
      cout << personlist << endl;
}
示例#2
0
void DOMParsePerson()
{
   PersonList personlist;
   gROOT->ProcessLine(".O 0");
   TString dir = gROOT->GetTutorialDir();
   if (personlist.ParseFile(dir+"/xml/person.xml") == 0)
      cout << personlist << endl;
}
示例#3
0
int main(int, char** argv)
{
    // Create list of persons:

    PersonList list;
    PEGASUS_TEST_ASSERT(list.size() == 0);
    list.insert_back(new Person("John"));
    PEGASUS_TEST_ASSERT(list.size() == 1);
    list.insert_back(new Person("Jane"));
    PEGASUS_TEST_ASSERT(list.size() == 2);
    list.insert_back(new Person("Joe"));
    PEGASUS_TEST_ASSERT(list.size() == 3);
    list.insert_back(new Person("Bob"));
    PEGASUS_TEST_ASSERT(list.size() == 4);

    // Print all elements of the list:

    {
    PersonList::AutoLock autoLock(list);

    for (Person* p = list.front(); p; p = list.next_of(p))
    {
        // p->print();
    }
    }

    // Find "John":

    {
    const String JOHN = "John";
    Person* john = list.find(Person::equal, &JOHN);
    PEGASUS_TEST_ASSERT(john);
    // john->print();
    }

    // Remove "John" and "Jane":
    {
    const String JOHN = "John";
    Person* john = list.remove(Person::equal, &JOHN);
    PEGASUS_TEST_ASSERT(john->name() == "John");
    delete john;
    PEGASUS_TEST_ASSERT(list.size() == 3);

    const String JANE = "Jane";
    Person* jane = list.remove(Person::equal, &JANE);
    PEGASUS_TEST_ASSERT(jane->name() == "Jane");
    delete jane;
    PEGASUS_TEST_ASSERT(list.size() == 2);
    }

    // Clear the list:
    {
    list.clear();
    PEGASUS_TEST_ASSERT(list.size() == 0);
    }

    cout << argv[0] << " +++++ passed all tests" << endl;

    return 0;
}