diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 13:29:23 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2015-10-21 13:29:23 -0400 |
commit | 316eb864137a0b8eeb0d0d4d698ba83f4946a89c (patch) | |
tree | 9268f9369d9382ca3ee8f7496ab71394dfa9daef /core/include/fpdfapi | |
parent | 43ce9035a026c7b4f15aa938dc39444d9253ea9f (diff) | |
download | pdfium-316eb864137a0b8eeb0d0d4d698ba83f4946a89c.tar.xz |
Merge to XFA: Add type cast definitions for CPDF_String.
This Cl adds ToString, CPDF_Object::AsString and CPDF_Object::IsString and
updates the src to use them as needed.
BUG=pdfium:201
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1417933002 .
(cherry picked from commit 53d3ab125ef583be8cfac907b308a6551b93067a)
Review URL: https://codereview.chromium.org/1408323006 .
Diffstat (limited to 'core/include/fpdfapi')
-rw-r--r-- | core/include/fpdfapi/fpdf_objects.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index 41b457799b..a790d349ad 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -83,6 +83,7 @@ class CPDF_Object { bool IsBoolean() const { return m_Type == PDFOBJ_BOOLEAN; } bool IsDictionary() const { return m_Type == PDFOBJ_DICTIONARY; } bool IsNumber() const { return m_Type == PDFOBJ_NUMBER; } + bool IsString() const { return m_Type == PDFOBJ_STRING; } CPDF_Boolean* AsBoolean(); const CPDF_Boolean* AsBoolean() const; @@ -93,6 +94,9 @@ class CPDF_Object { CPDF_Number* AsNumber(); const CPDF_Number* AsNumber() const; + CPDF_String* AsString(); + const CPDF_String* AsString() const; + protected: CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {} ~CPDF_Object() {} @@ -222,6 +226,13 @@ class CPDF_String : public CPDF_Object { FX_BOOL m_bHex; friend class CPDF_Object; }; +inline CPDF_String* ToString(CPDF_Object* obj) { + return obj ? obj->AsString() : nullptr; +} +inline const CPDF_String* ToString(const CPDF_Object* obj) { + return obj ? obj->AsString() : nullptr; +} + class CPDF_Name : public CPDF_Object { public: static CPDF_Name* Create(const CFX_ByteString& str) { |