diff options
Diffstat (limited to 'src/cos_object.h')
-rw-r--r-- | src/cos_object.h | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/src/cos_object.h b/src/cos_object.h index 632126e..a1a70ee 100644 --- a/src/cos_object.h +++ b/src/cos_object.h @@ -20,9 +20,13 @@ struct nspdf_doc; struct content_operation; struct cos_content; +struct cos_object; +/** + * The type of cos object in an entry. + */ enum cos_type { - COS_TYPE_NULL, /* 0 */ + COS_TYPE_NULL, /* 0 - NULL object */ COS_TYPE_BOOL, COS_TYPE_INT, COS_TYPE_REAL, @@ -37,8 +41,10 @@ enum cos_type { COS_TYPE_CONTENT, /* 12 - parsed content stream */ }; -struct cos_object; +/** + * list of COS dictionary entries. + */ struct cos_dictionary_entry { /** next key/value in dictionary */ struct cos_dictionary_entry *next; @@ -50,6 +56,7 @@ struct cos_dictionary_entry { struct cos_object *value; }; + /** * array of COS objects */ @@ -64,6 +71,7 @@ struct cos_array { struct cos_object **values; }; + /** * COS string data */ @@ -73,12 +81,29 @@ struct cos_string { uint8_t *data; /**< string data */ }; + +/** + * reference to COS object + */ struct cos_reference { uint64_t id; /**< id of indirect object */ uint64_t generation; /**< generation of indirect object */ }; +/** + * COS rectangle + */ +struct cos_rectangle { + float llx; /**< lower left x */ + float lly; /**< lower left y */ + float urx; /**< upper right x */ + float ury; /**< upper right y */ +}; + +/** + * Carosel object + */ struct cos_object { enum cos_type type; union { @@ -118,10 +143,11 @@ nspdferror cos_free_object(struct cos_object *cos_obj); /** - * extract a value for a key from a dictionary + * extract a value object for a key from a dictionary * - * This retrieves the value of a given key in a dictionary and removes it from - * the dictionary. + * This retrieves the value object of a given key in a dictionary and removes + * the entry from the dictionary. Once extracted the caller owns the returned + * object and must free it. * * \param dict The dictionary * \param key The key to lookup @@ -134,8 +160,13 @@ nspdferror cos_extract_dictionary_value(struct cos_object *dict, const char *key /** - * get a value for a key from a dictionary + * get a value object for a key from a dictionary + * + * Get the value for a key from a dictionary, If the dictionary is an object + * reference it will be dereferenced first which will parse any + * previously unreferenced indirect objects. * + * \param doc The document the cos object belongs to or NULL to supress dereferencing. * \param dict The dictionary * \param key The key to lookup * \param value_out The value object associated with the key @@ -146,7 +177,23 @@ nspdferror cos_extract_dictionary_value(struct cos_object *dict, const char *key nspdferror cos_get_dictionary_value(struct nspdf_doc *doc, struct cos_object *dict, const char *key, struct cos_object **value_out); -nspdferror cos_get_dictionary_int(struct nspdf_doc *doc, struct cos_object *dict, const char *key, int64_t *value_out); +/** + * get an integer value for a key from a dictionary + * + * Get the integer value for a key from a dictionary, If the dictionary is an + * object reference it will be dereferenced first which will parse any + * previously unreferenced indirect objects. + * + * \param doc The document the cos object belongs to or NULL to supress dereferencing. + * \param dict The dictionary + * \param key The key to lookup + * \param in_out The integer value associated with the key. + * \return NSPDFERROR_OK and value_out updated on success. + * NSPDFERROR_TYPE if the object passed in \p dict is not a dictionary + * or the value of the key is not an integer. + * NSPDFERROR_NOTFOUND if the key is not present in the dictionary. + */ +nspdferror cos_get_dictionary_int(struct nspdf_doc *doc, struct cos_object *dict, const char *key, int64_t *int_out); nspdferror cos_get_dictionary_name(struct nspdf_doc *doc, struct cos_object *dict, const char *key, const char **value_out); @@ -190,6 +237,7 @@ nspdferror cos_get_array_dictionary(struct nspdf_doc *doc, struct cos_object *ar */ nspdferror cos_get_int(struct nspdf_doc *doc, struct cos_object *cobj, int64_t *value_out); + /** * get the float value of a cos object. * @@ -205,6 +253,7 @@ nspdferror cos_get_int(struct nspdf_doc *doc, struct cos_object *cobj, int64_t * */ nspdferror cos_get_number(struct nspdf_doc *doc, struct cos_object *cobj, float *value_out); + /** * get the name value of a cos object. * @@ -268,6 +317,7 @@ nspdferror cos_get_dictionary(struct nspdf_doc *doc, struct cos_object *cobj, st */ nspdferror cos_get_array(struct nspdf_doc *doc, struct cos_object *cobj, struct cos_object **value_out); + /** * get the stream value of a cos object. * @@ -283,6 +333,7 @@ nspdferror cos_get_array(struct nspdf_doc *doc, struct cos_object *cobj, struct */ nspdferror cos_get_stream(struct nspdf_doc *doc, struct cos_object *cobj, struct cos_stream **stream_out); + /** * get a direct cos object. * @@ -296,6 +347,7 @@ nspdferror cos_get_stream(struct nspdf_doc *doc, struct cos_object *cobj, struct */ nspdferror cos_get_object(struct nspdf_doc *doc, struct cos_object *cobj, struct cos_object **object_out); + /** * get a parsed content object * @@ -310,4 +362,17 @@ nspdferror cos_get_object(struct nspdf_doc *doc, struct cos_object *cobj, struct */ nspdferror cos_get_content(struct nspdf_doc *doc, struct cos_object *cobj, struct cos_content **content_out); + +/** + * Get a rectangle + * + * Generates a synthetic rectangle object from a array of four numbers + * + * \param doc The document the cos object belongs to. + * \param cobj A cos object. + * \param rect_out The result rectangle. + * \return NSERROR_OK and \p rect_out updated, + */ +nspdferror cos_get_rectangle(struct nspdf_doc *doc, struct cos_object *cobj, struct cos_rectangle *rect_out); + #endif |