Re: [Podofo-users] [PATCH 10/13] PdfVariant: Added SetString method

2018-04-27 Thread Francesco Pretto
On 27 April 2018 at 17:17, Matthew Brincke  wrote:
> so please avoid sending patches in-line
> in a post, please send all as attachments.
>

Sure, this has already been clarified with zyx some times ago.
Thank you for reviews.

Cheers,
Francesco

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] [PATCH 10/13] PdfVariant: Added SetString method

2018-04-27 Thread Matthew Brincke
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 )
+{
+DelayedLoad();
+
+if (!IsString())
+{
+PODOFO_RAISE_ERROR(ePdfError_InvalidDataType);
+}
+
+AssertMutable();
+*((PdfString*)m_Data.pData) = str;
+SetDirty(true);
 }
 
 // -

#include 
#include 

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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


[Podofo-users] [PATCH 10/13] PdfVariant: Added SetString method

2018-02-22 Thread Francesco Pretto

---
 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 d the string value
+*
+*  This will set the dirty flag of this object.
+*  \see IsDirty
+*/
+inline void SetString(const PdfString &);
 
 /** \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 )
+{
+DelayedLoad();
+
+if (!IsString())
+{
+PODOFO_RAISE_ERROR(ePdfError_InvalidDataType);
+}
+
+AssertMutable();
+*((PdfString*)m_Data.pData) = str;
+SetDirty(true);
 }
 
 // -

--
2.16.1.windows.1



--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users