Hello Francesco, hello all,
On 22 February 2018 at 12:21 Francesco Pretto wrote:
> ---
> src/base/PdfVariant.h | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
the patch looks good except for the fact I had to
massage the white-space to get it to apply as a patch
(without fuzz), so please avoid sending patches in-line
in a post, please send all as attachments.
I've attached the final patch file here, as well as the
test program I used to test the change in a Debian sid
up-to-date sbuild chroot (against version 0.9.5-9 of
libpodofo0.9.5). I'm sorry that I had put off this test
for so long.
Thanks for your patch, I've committed it in the attached,
final form to svn r1922:
https://sourceforge.net/p/podofo/code/1922
Best regards, mabri
---
src/base/PdfVariant.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/base/PdfVariant.h b/src/base/PdfVariant.h
index f9217d8..fbd3c32 100644
--- a/src/base/PdfVariant.h
+++ b/src/base/PdfVariant.h
@@ -275,6 +275,14 @@ class PODOFO_API PdfVariant {
* \return the value of the number
*/
inline double GetReal() const;
+
+ /** Set the string value of this object.
+ * \param str the string value
+ *
+ * This will set the dirty flag of this object.
+ * \see IsDirty
+ */
+ inline void SetString(const PdfString & str);
/** \returns the value of the object as string.
*/
@@ -722,6 +730,23 @@ PdfData & PdfVariant::GetRawData()
// We need a c-style casts here to avoid crashes
// because a reinterpret_cast might point to a different position.
return *((PdfData*)m_Data.pData);
+}
+
+// -----------------------------------------------------
+//
+// -----------------------------------------------------
+void PdfVariant::SetString(const PdfString &str)
+{
+ DelayedLoad();
+
+ if (!IsString())
+ {
+ PODOFO_RAISE_ERROR(ePdfError_InvalidDataType);
+ }
+
+ AssertMutable();
+ *((PdfString*)m_Data.pData) = str;
+ SetDirty(true);
}
// -----------------------------------------------------
#include <podofo/podofo.h>
#include <iostream>
using namespace PoDoFo;
int main() {
PdfVariant testVar(PdfString("Test string"));
std::cerr << "Test: testVar contains " << testVar.GetString().GetStringUtf8()
<< std::endl;
testVar.SetString("Another test");
std::cerr << "Now in testVar (exp: Another test): "
<< testVar.GetString().GetStringUtf8() << std::endl;
return 0;
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users