summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-10 18:45:55 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-10 18:45:55 -0700
commit10a285391c74845898830f8167bcfc467665b0f8 (patch)
tree50d4d131fd0ecb1b90f36f151a0f7cc530e99853 /core/fpdfapi
parent836f7d5d23b0951c8be86ccca54ebad43179febe (diff)
downloadpdfium-10a285391c74845898830f8167bcfc467665b0f8.tar.xz
Move ToString() and friends from CPDF_Object.h to CPDF_String.h
Ditto with the other ToXXX functions to CPDF_xxx.h. Shortly, we will want to introduce another variant: inline std::unique_ptr<CPDF_String> ToString( std::unique_ptr<CPDF_Object>); This will require that CPDF_String be complete which is not the case in the CPDF_Object.h header. Rather than dragging all the other .h's into it, move these to the subclass headers. That way, these will be together when the new form is added. Review-Url: https://codereview.chromium.org/2406033002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp1
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp1
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp1
-rw-r--r--core/fpdfapi/parser/cpdf_array.h8
-rw-r--r--core/fpdfapi/parser/cpdf_boolean.h8
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.h8
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp1
-rw-r--r--core/fpdfapi/parser/cpdf_name.h8
-rw-r--r--core/fpdfapi/parser/cpdf_number.h8
-rw-r--r--core/fpdfapi/parser/cpdf_object.h63
-rw-r--r--core/fpdfapi/parser/cpdf_reference.h8
-rw-r--r--core/fpdfapi/parser/cpdf_stream.h8
-rw-r--r--core/fpdfapi/parser/cpdf_string.h8
13 files changed, 68 insertions, 63 deletions
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 24ce4e8865..e79f16a001 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/page/pageint.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fxcrt/fx_system.h"
#include "third_party/base/stl_util.h"
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 5bfd6dedb6..6925f691c9 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -14,6 +14,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index e1472c95a7..dbe35b4714 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -11,6 +11,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fpdfapi/parser/cpdf_stream.h"
namespace {
diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h
index da9677e927..46e9d47667 100644
--- a/core/fpdfapi/parser/cpdf_array.h
+++ b/core/fpdfapi/parser/cpdf_array.h
@@ -70,4 +70,12 @@ class CPDF_Array : public CPDF_Object {
std::vector<CPDF_Object*> m_Objects;
};
+inline CPDF_Array* ToArray(CPDF_Object* obj) {
+ return obj ? obj->AsArray() : nullptr;
+}
+
+inline const CPDF_Array* ToArray(const CPDF_Object* obj) {
+ return obj ? obj->AsArray() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_
diff --git a/core/fpdfapi/parser/cpdf_boolean.h b/core/fpdfapi/parser/cpdf_boolean.h
index 89ed17d743..91b99f6dd2 100644
--- a/core/fpdfapi/parser/cpdf_boolean.h
+++ b/core/fpdfapi/parser/cpdf_boolean.h
@@ -32,4 +32,12 @@ class CPDF_Boolean : public CPDF_Object {
bool m_bValue;
};
+inline CPDF_Boolean* ToBoolean(CPDF_Object* obj) {
+ return obj ? obj->AsBoolean() : nullptr;
+}
+
+inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) {
+ return obj ? obj->AsBoolean() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_BOOLEAN_H_
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index b56e40a6ef..9cf575ddd4 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -98,4 +98,12 @@ class CPDF_Dictionary : public CPDF_Object {
std::map<CFX_ByteString, CPDF_Object*> m_Map;
};
+inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
+ return obj ? obj->AsDictionary() : nullptr;
+}
+
+inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
+ return obj ? obj->AsDictionary() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 0e688c685b..a5bf39d438 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -16,6 +16,7 @@
#include "core/fpdfapi/page/pageint.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
diff --git a/core/fpdfapi/parser/cpdf_name.h b/core/fpdfapi/parser/cpdf_name.h
index e6b460de39..cfc2fe641a 100644
--- a/core/fpdfapi/parser/cpdf_name.h
+++ b/core/fpdfapi/parser/cpdf_name.h
@@ -29,4 +29,12 @@ class CPDF_Name : public CPDF_Object {
CFX_ByteString m_Name;
};
+inline CPDF_Name* ToName(CPDF_Object* obj) {
+ return obj ? obj->AsName() : nullptr;
+}
+
+inline const CPDF_Name* ToName(const CPDF_Object* obj) {
+ return obj ? obj->AsName() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_NAME_H_
diff --git a/core/fpdfapi/parser/cpdf_number.h b/core/fpdfapi/parser/cpdf_number.h
index 8c708e93f1..a5efc1423e 100644
--- a/core/fpdfapi/parser/cpdf_number.h
+++ b/core/fpdfapi/parser/cpdf_number.h
@@ -41,4 +41,12 @@ class CPDF_Number : public CPDF_Object {
};
};
+inline CPDF_Number* ToNumber(CPDF_Object* obj) {
+ return obj ? obj->AsNumber() : nullptr;
+}
+
+inline const CPDF_Number* ToNumber(const CPDF_Object* obj) {
+ return obj ? obj->AsNumber() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_NUMBER_H_
diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h
index 75400f3a53..e2c30b96ca 100644
--- a/core/fpdfapi/parser/cpdf_object.h
+++ b/core/fpdfapi/parser/cpdf_object.h
@@ -117,67 +117,4 @@ class CPDF_Object {
CPDF_Object(const CPDF_Object& src) {}
};
-inline CPDF_Boolean* ToBoolean(CPDF_Object* obj) {
- return obj ? obj->AsBoolean() : nullptr;
-}
-
-inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) {
- return obj ? obj->AsBoolean() : nullptr;
-}
-
-inline CPDF_Number* ToNumber(CPDF_Object* obj) {
- return obj ? obj->AsNumber() : nullptr;
-}
-
-inline const CPDF_Number* ToNumber(const CPDF_Object* obj) {
- return obj ? obj->AsNumber() : nullptr;
-}
-
-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;
-}
-
-inline CPDF_Name* ToName(CPDF_Object* obj) {
- return obj ? obj->AsName() : nullptr;
-}
-
-inline const CPDF_Name* ToName(const CPDF_Object* obj) {
- return obj ? obj->AsName() : nullptr;
-}
-
-inline CPDF_Array* ToArray(CPDF_Object* obj) {
- return obj ? obj->AsArray() : nullptr;
-}
-
-inline const CPDF_Array* ToArray(const CPDF_Object* obj) {
- return obj ? obj->AsArray() : nullptr;
-}
-
-inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
- return obj ? obj->AsDictionary() : nullptr;
-}
-
-inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
- return obj ? obj->AsDictionary() : nullptr;
-}
-inline CPDF_Reference* ToReference(CPDF_Object* obj) {
- return obj ? obj->AsReference() : nullptr;
-}
-
-inline const CPDF_Reference* ToReference(const CPDF_Object* obj) {
- return obj ? obj->AsReference() : nullptr;
-}
-
-inline CPDF_Stream* ToStream(CPDF_Object* obj) {
- return obj ? obj->AsStream() : nullptr;
-}
-
-inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
- return obj ? obj->AsStream() : nullptr;
-}
-
#endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
diff --git a/core/fpdfapi/parser/cpdf_reference.h b/core/fpdfapi/parser/cpdf_reference.h
index 8c57d85e0e..5221832f80 100644
--- a/core/fpdfapi/parser/cpdf_reference.h
+++ b/core/fpdfapi/parser/cpdf_reference.h
@@ -47,4 +47,12 @@ class CPDF_Reference : public CPDF_Object {
uint32_t m_RefObjNum;
};
+inline CPDF_Reference* ToReference(CPDF_Object* obj) {
+ return obj ? obj->AsReference() : nullptr;
+}
+
+inline const CPDF_Reference* ToReference(const CPDF_Object* obj) {
+ return obj ? obj->AsReference() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_REFERENCE_H_
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index 6a4f1011c0..ed266778b3 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -58,4 +58,12 @@ class CPDF_Stream : public CPDF_Object {
IFX_FileRead* m_pFile = nullptr;
};
+inline CPDF_Stream* ToStream(CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+
+inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
+ return obj ? obj->AsStream() : nullptr;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h
index d99e00c403..01ea8224d4 100644
--- a/core/fpdfapi/parser/cpdf_string.h
+++ b/core/fpdfapi/parser/cpdf_string.h
@@ -36,4 +36,12 @@ class CPDF_String : public CPDF_Object {
FX_BOOL m_bHex;
};
+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;
+}
+
#endif // CORE_FPDFAPI_PARSER_CPDF_STRING_H_