#include "classad/classad.h" #include "classad/classad_distribution.h" #includeint main() { classad::ClassAd ad; ad.Insert("key1", "value1"); ad.Insert("key2", "value2"); classad::LookupString lookup; lookup.Evaluate(&ad, "key1"); std::cout << "The value of key1 is: " << lookup.Value() << std::endl; return 0; }
#include "classad/classad.h" #include "classad/classad_distribution.h" #includeIn this example, we create a ClassAd object with two key-value pairs. We then create a LookupString object and use the Evaluate method to look up the value associated with "key3". Since "key3" does not exist in the ClassAd, the Evaluate method returns false and we print a message indicating the key was not found. The ClassAd package library is provided by the HTCondor project as a means of describing and manipulating computational resources.int main() { classad::ClassAd ad; ad.Insert("key1", "value1"); ad.Insert("key2", "value2"); classad::LookupString lookup; bool found = lookup.Evaluate(&ad, "key3"); if (found) { std::cout << "The value of key3 is: " << lookup.Value() << std::endl; } else { std::cout << "key3 not found" << std::endl; } return 0; }