summaryrefslogtreecommitdiff
path: root/core/include
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-21 13:08:24 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-21 13:08:24 -0400
commit53d3ab125ef583be8cfac907b308a6551b93067a (patch)
tree7680ace0f99bb5aa2532def62411d7e59360793f /core/include
parent83bf02dfb860a66d756434d194118dae572d04d3 (diff)
downloadpdfium-53d3ab125ef583be8cfac907b308a6551b93067a.tar.xz
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 .
Diffstat (limited to 'core/include')
-rw-r--r--core/include/fpdfapi/fpdf_objects.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index 438c89cc50..c3e5df4118 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -81,6 +81,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;
@@ -91,6 +92,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() {}
@@ -220,6 +224,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) {