Commit aa0a379b37889caad022ec12fba76990b2e2e2d9

Authored by Jay Berkenbilt
1 parent 5c5e5ca2

Add JSON::isDictionary and JSON::isArray

ChangeLog
... ... @@ -4,6 +4,10 @@
4 4 to QPDFObjectHandle with corresponding functions added to the C
5 5 API. Thanks to m-holger for the contribution.
6 6  
  7 +2022-01-17 Jay Berkenbilt <ejb@ql.org>
  8 +
  9 + * Add isDictionary and isArray to JSON
  10 +
7 11 2022-01-11 Jay Berkenbilt <ejb@ql.org>
8 12  
9 13 * Bug fix: add missing characters from PDF doc encoding.
... ...
include/qpdf/JSON.hh
... ... @@ -69,6 +69,12 @@ class JSON
69 69 QPDF_DLL
70 70 static JSON makeNull();
71 71  
  72 + QPDF_DLL
  73 + bool isArray() const;
  74 +
  75 + QPDF_DLL
  76 + bool isDictionary() const;
  77 +
72 78 // Check this JSON object against a "schema". This is not a schema
73 79 // according to any standard. It's just a template of what the
74 80 // JSON is supposed to contain. The checking does the following:
... ...
libqpdf/JSON.cc
... ... @@ -294,6 +294,20 @@ JSON::makeNull()
294 294 }
295 295  
296 296 bool
  297 +JSON::isArray() const
  298 +{
  299 + return nullptr != dynamic_cast<JSON_array const*>(
  300 + this->m->value.getPointer());
  301 +}
  302 +
  303 +bool
  304 +JSON::isDictionary() const
  305 +{
  306 + return nullptr != dynamic_cast<JSON_dictionary const*>(
  307 + this->m->value.getPointer());
  308 +}
  309 +
  310 +bool
297 311 JSON::checkSchema(JSON schema, std::list<std::string>& errors)
298 312 {
299 313 return checkSchemaInternal(this->m->value.getPointer(),
... ...