Browse Source

Add c-api methods to destroy global_settings and object settings

Note that one does not normally need to do this since they are consumed by the converter object,
however if you like to keep your objects in a unique_ptr until they are consumed this is for you
Jakob Truelsen 11 years ago
parent
commit
51036e6864
2 changed files with 24 additions and 0 deletions
  1. 3 0
      include/wkhtmltox/pdf.h
  2. 21 0
      src/lib/pdf_c_bindings.cc

+ 3 - 0
include/wkhtmltox/pdf.h

@@ -40,7 +40,10 @@ CAPI(int) wkhtmltopdf_extended_qt();
 CAPI(const char *) wkhtmltopdf_version();
 
 CAPI(wkhtmltopdf_global_settings *) wkhtmltopdf_create_global_settings();
+CAPI(void) wkhtmltopdf_destroy_global_settings(wkhtmltopdf_global_settings *);
+
 CAPI(wkhtmltopdf_object_settings *) wkhtmltopdf_create_object_settings();
+CAPI(void) wkhtmltopdf_destroy_object_settings(wkhtmltopdf_global_settings *);
 
 CAPI(int) wkhtmltopdf_set_global_setting(wkhtmltopdf_global_settings * settings, const char * name, const char * value);
 CAPI(int) wkhtmltopdf_get_global_setting(wkhtmltopdf_global_settings * settings, const char * name, char * value, int vs);

+ 21 - 0
src/lib/pdf_c_bindings.cc

@@ -341,6 +341,16 @@ CAPI(wkhtmltopdf_global_settings *) wkhtmltopdf_create_global_settings() {
 	return reinterpret_cast<wkhtmltopdf_global_settings *>(new settings::PdfGlobal());
 }
 
+/**
+ * \brief Destroy a global settings  object
+ *
+ * Normally one would not need to call this since ownership of the
+ * settings object is transfarred to the converter.
+ */
+CAPI(void) wkhtmltopdf_destroy_global_settings(wkhtmltopdf_global_settings * obj) {
+	delete reinterpret_cast<settings::PdfGlobal *>(obj);
+}
+
 /**
  * \brief Alter a setting in a global settings object
  *
@@ -387,6 +397,17 @@ CAPI(wkhtmltopdf_object_settings *) wkhtmltopdf_create_object_settings() {
 	return reinterpret_cast<wkhtmltopdf_object_settings *>(new settings::PdfObject());
 }
 
+/**
+ * \brief Destroy a global settings  object
+ *
+ * Normally one would not need to call this since ownership of the
+ * settings object is transfarred to the converter.
+ */
+CAPI(void) wkhtmltopdf_destroy_object_settings(wkhtmltopdf_object_settings * obj) {
+	delete reinterpret_cast<settings::PdfObject *>(obj);
+}
+
+
 /**
  * \brief Alter a setting in a object settings object
  *