Hello Francesco, hello all,
> On 22 February 2018 at 12:21 Francesco Pretto wrote:
>
>
> Also added a convenience GetSize() method
> ---
> src/base/PdfDictionary.cpp | 10 ++
> src/base/PdfDictionary.h | 16 +++-
> 2 files changed, 25 insertions(+), 1 deletion(-)
>
your patch looks fine (except that it wouldn't apply without ignoring
white-space and some removals of that) and I've tested it OK in two
environments: a Debian sid chroot (with the Debian revision as a base,
GCC 7 compiler) and a sandbox with the current svn revision, but only
GCC 4.9.2). Therefore I've committed it as svn r1928:
https://sourceforge.net/p/podofo/code/1928/
I'm sorry for having taken my time (so much) with the testing (test
attached, committed version of patch also, first).
Best regards, mabriIndex: src/base/PdfDictionary.cpp
===
--- src/base/PdfDictionary.cpp (revision 1927)
+++ src/base/PdfDictionary.cpp (working copy)
@@ -357,4 +357,14 @@
}
}
+TCIKeyMap PdfDictionary::begin() const
+{
+return m_mapKeys.begin();
+}
+
+TCIKeyMap PdfDictionary::end() const
+{
+return m_mapKeys.end();
+}
+
};
Index: src/base/PdfDictionary.h
===
--- src/base/PdfDictionary.h (revision 1927)
+++ src/base/PdfDictionary.h (working copy)
@@ -229,6 +229,11 @@
void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode,
const PdfEncrypt* pEncrypt, const PdfName & keyStop = PdfName::KeyNull ) const;
+/**
+* \returns the size of the internal map
+*/
+inline size_t GetSize() const;
+
/** Get access to the internal map of keys.
*
* \returns all keys of this dictionary
@@ -262,6 +267,10 @@
*/
virtual void SetDirty( bool bDirty );
+ public:
+ TCIKeyMap begin() const;
+ TCIKeyMap end() const;
+
private:
TKeyMap m_mapKeys;
@@ -272,6 +281,11 @@
typedef TVecDictionaries::iterator TIVecDictionaries;
typedef TVecDictionaries::const_iterator TCIVecDictionaries;
+size_t PdfDictionary::GetSize() const
+{
+return m_mapKeys.size();
+}
+
// -
//
// -
#include
#include
using namespace PoDoFo;
int main()
{
PdfError::EnableDebug(true);
PdfDictionary testDict;
testDict.AddKey(PdfName("Name"), PdfString("Test"));
testDict.AddKey(PdfName("F"), PdfString("test.txt"));
testDict.AddKey(PdfName("UF"), PdfString("Test.txt"));
for (const auto& testElem: testDict)
{
std::string objString;
PdfError::DebugMessage("Current element name: %s value: %s\n",
testElem.first.GetName().c_str(),
(testElem.second->ToString(objString), objString.c_str()));
}
PdfError::DebugMessage("Size of dictionary: %zu\n", testDict.GetSize());
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