CPDF_Dictionary dict; // add some key-value pairs to the dictionary dict.SetNewFor("foo", 123); dict.SetNewFor ("bar", "hello world"); // get the underlying dictionary object CPDF_Dictionary* underlying_dict = dict.GetDict(); // access the values directly CPDF_Object* foo_value = underlying_dict->GetDirectObject("foo"); CPDF_Object* bar_value = underlying_dict->GetDirectObject("bar"); // do something with the values if (foo_value && foo_value->GetType() == CPDF_Object::NUMBER) { int foo_int = ToNumber(foo_value)->GetInteger(); // ... } if (bar_value && bar_value->GetType() == CPDF_Object::STRING) { ByteString bar_string = ToString(bar_value)->GetByteString(); // ... }
CPDF_Object* obj = // some PDF object, e.g. a stream or array if (obj->GetType() == CPDF_Object::DICTIONARY) { CPDF_Dictionary* dict = ToDictionary(obj); CPDF_Dictionary* parent_dict = dict->GetDict("Parent", CPDF_Object::DICTIONARY); if (parent_dict) { // do something with the parent dictionary } }This example shows how to use GetDict to get a pointer to a dictionary object that is a value in another dictionary. In this case, we start with a PDF object of some type (e.g. a stream or array), check if it is a dictionary, and then use GetDict to retrieve the "Parent" key, which is expected to be a dictionary. We use the optional second argument to specify the expected type of the value (in case it is absent or of the wrong type), and then perform some operation on the returned dictionary if it exists. Based on the class name and function signature, it is likely that CPDF_Dictionary is part of a PDF rendering or manipulation library, possibly one that provides low-level access to the PDF data structures. However, without more context it is difficult to determine the specific library or package.