Commit c7005e8a6d626d1c66bd780314c2520d12b0ca9a

Authored by m-holger
1 parent 27fae2b5

Remove virtual methods QPDFValue::getTypeCode and getTypeName

include/qpdf/QPDFObject.hh
... ... @@ -87,7 +87,7 @@ class QPDFObject
87 87 object_type_e
88 88 getTypeCode() const
89 89 {
90   - return value->getTypeCode();
  90 + return value->type_code;
91 91 }
92 92  
93 93 // Return a string literal that describes the type, useful for
... ... @@ -95,9 +95,8 @@ class QPDFObject
95 95 char const*
96 96 getTypeName() const
97 97 {
98   - return value->getTypeName();
  98 + return value->type_name;
99 99 }
100   -
101 100 void
102 101 setDescription(QPDF* qpdf, std::string const& description)
103 102 {
... ...
include/qpdf/QPDFValue.hh
... ... @@ -43,8 +43,6 @@ class QPDFValue
43 43 virtual std::shared_ptr<QPDFObject> shallowCopy() = 0;
44 44 virtual std::string unparse() = 0;
45 45 virtual JSON getJSON(int json_version) = 0;
46   - virtual qpdf_object_type_e getTypeCode() const = 0;
47   - virtual char const* getTypeName() const = 0;
48 46 virtual void
49 47 setDescription(QPDF* qpdf, std::string const& description)
50 48 {
... ... @@ -75,7 +73,17 @@ class QPDFValue
75 73 }
76 74  
77 75 protected:
78   - QPDFValue() = default;
  76 + QPDFValue() :
  77 + type_code(::ot_uninitialized),
  78 + type_name("uninitilized")
  79 + {
  80 + }
  81 + QPDFValue(qpdf_object_type_e type_code, char const* type_name) :
  82 + type_code(type_code),
  83 + type_name(type_name)
  84 + {
  85 + }
  86 +
79 87 virtual void
80 88 releaseResolved()
81 89 {
... ... @@ -88,6 +96,8 @@ class QPDFValue
88 96 QPDF* owning_qpdf{nullptr};
89 97 std::string object_description;
90 98 qpdf_offset_t parsed_offset{-1};
  99 + const qpdf_object_type_e type_code;
  100 + char const* type_name;
91 101 };
92 102  
93 103 #endif // QPDFVALUE_HH
... ...
libqpdf/QPDF_Array.cc
... ... @@ -4,12 +4,14 @@
4 4 #include <qpdf/QUtil.hh>
5 5 #include <stdexcept>
6 6  
7   -QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& v)
  7 +QPDF_Array::QPDF_Array(std::vector<QPDFObjectHandle> const& v) :
  8 + QPDFValue(::ot_array, "array")
8 9 {
9 10 setFromVector(v);
10 11 }
11 12  
12 13 QPDF_Array::QPDF_Array(SparseOHArray const& items) :
  14 + QPDFValue(::ot_array, "array"),
13 15 elements(items)
14 16 {
15 17 }
... ... @@ -62,18 +64,6 @@ QPDF_Array::getJSON(int json_version)
62 64 return j;
63 65 }
64 66  
65   -qpdf_object_type_e
66   -QPDF_Array::getTypeCode() const
67   -{
68   - return ::ot_array;
69   -}
70   -
71   -char const*
72   -QPDF_Array::getTypeName() const
73   -{
74   - return "array";
75   -}
76   -
77 67 int
78 68 QPDF_Array::getNItems() const
79 69 {
... ...
libqpdf/QPDF_Bool.cc
1 1 #include <qpdf/QPDF_Bool.hh>
2 2  
3 3 QPDF_Bool::QPDF_Bool(bool val) :
  4 + QPDFValue(::ot_boolean, "boolean"),
4 5 val(val)
5 6 {
6 7 }
... ... @@ -29,18 +30,6 @@ QPDF_Bool::getJSON(int json_version)
29 30 return JSON::makeBool(this->val);
30 31 }
31 32  
32   -qpdf_object_type_e
33   -QPDF_Bool::getTypeCode() const
34   -{
35   - return ::ot_boolean;
36   -}
37   -
38   -char const*
39   -QPDF_Bool::getTypeName() const
40   -{
41   - return "boolean";
42   -}
43   -
44 33 bool
45 34 QPDF_Bool::getVal() const
46 35 {
... ...
libqpdf/QPDF_Dictionary.cc
... ... @@ -4,6 +4,7 @@
4 4  
5 5 QPDF_Dictionary::QPDF_Dictionary(
6 6 std::map<std::string, QPDFObjectHandle> const& items) :
  7 + QPDFValue(::ot_dictionary, "dictionary"),
7 8 items(items)
8 9 {
9 10 }
... ... @@ -57,18 +58,6 @@ QPDF_Dictionary::getJSON(int json_version)
57 58 return j;
58 59 }
59 60  
60   -qpdf_object_type_e
61   -QPDF_Dictionary::getTypeCode() const
62   -{
63   - return ::ot_dictionary;
64   -}
65   -
66   -char const*
67   -QPDF_Dictionary::getTypeName() const
68   -{
69   - return "dictionary";
70   -}
71   -
72 61 bool
73 62 QPDF_Dictionary::hasKey(std::string const& key)
74 63 {
... ...
libqpdf/QPDF_InlineImage.cc
1 1 #include <qpdf/QPDF_InlineImage.hh>
2 2  
3 3 QPDF_InlineImage::QPDF_InlineImage(std::string const& val) :
  4 + QPDFValue(::ot_inlineimage, "inline-image"),
4 5 val(val)
5 6 {
6 7 }
... ... @@ -29,18 +30,6 @@ QPDF_InlineImage::getJSON(int json_version)
29 30 return JSON::makeNull();
30 31 }
31 32  
32   -qpdf_object_type_e
33   -QPDF_InlineImage::getTypeCode() const
34   -{
35   - return ::ot_inlineimage;
36   -}
37   -
38   -char const*
39   -QPDF_InlineImage::getTypeName() const
40   -{
41   - return "inline-image";
42   -}
43   -
44 33 std::string
45 34 QPDF_InlineImage::getVal() const
46 35 {
... ...
libqpdf/QPDF_Integer.cc
... ... @@ -3,6 +3,7 @@
3 3 #include <qpdf/QUtil.hh>
4 4  
5 5 QPDF_Integer::QPDF_Integer(long long val) :
  6 + QPDFValue(::ot_integer, "integer"),
6 7 val(val)
7 8 {
8 9 }
... ... @@ -31,18 +32,6 @@ QPDF_Integer::getJSON(int json_version)
31 32 return JSON::makeInt(this->val);
32 33 }
33 34  
34   -qpdf_object_type_e
35   -QPDF_Integer::getTypeCode() const
36   -{
37   - return ::ot_integer;
38   -}
39   -
40   -char const*
41   -QPDF_Integer::getTypeName() const
42   -{
43   - return "integer";
44   -}
45   -
46 35 long long
47 36 QPDF_Integer::getVal() const
48 37 {
... ...
libqpdf/QPDF_Name.cc
... ... @@ -5,6 +5,7 @@
5 5 #include <string.h>
6 6  
7 7 QPDF_Name::QPDF_Name(std::string const& name) :
  8 + QPDFValue(::ot_name, "name"),
8 9 name(name)
9 10 {
10 11 }
... ... @@ -61,18 +62,6 @@ QPDF_Name::getJSON(int json_version)
61 62 }
62 63 }
63 64  
64   -qpdf_object_type_e
65   -QPDF_Name::getTypeCode() const
66   -{
67   - return ::ot_name;
68   -}
69   -
70   -char const*
71   -QPDF_Name::getTypeName() const
72   -{
73   - return "name";
74   -}
75   -
76 65 std::string
77 66 QPDF_Name::getName() const
78 67 {
... ...
libqpdf/QPDF_Null.cc
1 1 #include <qpdf/QPDF_Null.hh>
2 2  
  3 +QPDF_Null::QPDF_Null() :
  4 + QPDFValue(::ot_null, "null")
  5 +{
  6 +}
  7 +
3 8 std::shared_ptr<QPDFObject>
4 9 QPDF_Null::create()
5 10 {
... ... @@ -23,15 +28,3 @@ QPDF_Null::getJSON(int json_version)
23 28 {
24 29 return JSON::makeNull();
25 30 }
26   -
27   -qpdf_object_type_e
28   -QPDF_Null::getTypeCode() const
29   -{
30   - return ::ot_null;
31   -}
32   -
33   -char const*
34   -QPDF_Null::getTypeName() const
35   -{
36   - return "null";
37   -}
... ...
libqpdf/QPDF_Operator.cc
1 1 #include <qpdf/QPDF_Operator.hh>
2 2  
3 3 QPDF_Operator::QPDF_Operator(std::string const& val) :
  4 + QPDFValue(::ot_operator, "operator"),
4 5 val(val)
5 6 {
6 7 }
... ... @@ -29,18 +30,6 @@ QPDF_Operator::getJSON(int json_version)
29 30 return JSON::makeNull();
30 31 }
31 32  
32   -qpdf_object_type_e
33   -QPDF_Operator::getTypeCode() const
34   -{
35   - return ::ot_operator;
36   -}
37   -
38   -char const*
39   -QPDF_Operator::getTypeName() const
40   -{
41   - return "operator";
42   -}
43   -
44 33 std::string
45 34 QPDF_Operator::getVal() const
46 35 {
... ...
libqpdf/QPDF_Real.cc
... ... @@ -3,12 +3,14 @@
3 3 #include <qpdf/QUtil.hh>
4 4  
5 5 QPDF_Real::QPDF_Real(std::string const& val) :
  6 + QPDFValue(::ot_real, "real"),
6 7 val(val)
7 8 {
8 9 }
9 10  
10 11 QPDF_Real::QPDF_Real(
11 12 double value, int decimal_places, bool trim_trailing_zeroes) :
  13 + QPDFValue(::ot_real, "real"),
12 14 val(QUtil::double_to_string(value, decimal_places, trim_trailing_zeroes))
13 15 {
14 16 }
... ... @@ -60,18 +62,6 @@ QPDF_Real::getJSON(int json_version)
60 62 return JSON::makeNumber(result);
61 63 }
62 64  
63   -qpdf_object_type_e
64   -QPDF_Real::getTypeCode() const
65   -{
66   - return ::ot_real;
67   -}
68   -
69   -char const*
70   -QPDF_Real::getTypeName() const
71   -{
72   - return "real";
73   -}
74   -
75 65 std::string
76 66 QPDF_Real::getVal()
77 67 {
... ...
libqpdf/QPDF_Reserved.cc
... ... @@ -2,6 +2,11 @@
2 2  
3 3 #include <stdexcept>
4 4  
  5 +QPDF_Reserved::QPDF_Reserved() :
  6 + QPDFValue(::ot_reserved, "reserved")
  7 +{
  8 +}
  9 +
5 10 std::shared_ptr<QPDFObject>
6 11 QPDF_Reserved::create()
7 12 {
... ... @@ -29,15 +34,3 @@ QPDF_Reserved::getJSON(int json_version)
29 34 "QPDFObjectHandle: attempting to unparse a reserved object");
30 35 return JSON::makeNull();
31 36 }
32   -
33   -qpdf_object_type_e
34   -QPDF_Reserved::getTypeCode() const
35   -{
36   - return ::ot_reserved;
37   -}
38   -
39   -char const*
40   -QPDF_Reserved::getTypeName() const
41   -{
42   - return "reserved";
43   -}
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -114,6 +114,7 @@ QPDF_Stream::QPDF_Stream(
114 114 QPDFObjectHandle stream_dict,
115 115 qpdf_offset_t offset,
116 116 size_t length) :
  117 + QPDFValue(::ot_stream, "stream"),
117 118 qpdf(qpdf),
118 119 og(og),
119 120 filter_on_write(true),
... ... @@ -291,18 +292,6 @@ QPDF_Stream::getStreamJSON(
291 292 return result;
292 293 }
293 294  
294   -qpdf_object_type_e
295   -QPDF_Stream::getTypeCode() const
296   -{
297   - return ::ot_stream;
298   -}
299   -
300   -char const*
301   -QPDF_Stream::getTypeName() const
302   -{
303   - return "stream";
304   -}
305   -
306 295 void
307 296 QPDF_Stream::setDescription(QPDF* qpdf, std::string const& description)
308 297 {
... ...
libqpdf/QPDF_String.cc
... ... @@ -21,6 +21,7 @@ is_iso_latin1_printable(char ch)
21 21 }
22 22  
23 23 QPDF_String::QPDF_String(std::string const& val) :
  24 + QPDFValue(::ot_string, "string"),
24 25 val(val)
25 26 {
26 27 }
... ... @@ -84,18 +85,6 @@ QPDF_String::getJSON(int json_version)
84 85 return JSON::makeString(result);
85 86 }
86 87  
87   -qpdf_object_type_e
88   -QPDF_String::getTypeCode() const
89   -{
90   - return ::ot_string;
91   -}
92   -
93   -char const*
94   -QPDF_String::getTypeName() const
95   -{
96   - return "string";
97   -}
98   -
99 88 bool
100 89 QPDF_String::useHexString() const
101 90 {
... ...
libqpdf/QPDF_Unresolved.cc
... ... @@ -2,6 +2,11 @@
2 2  
3 3 #include <stdexcept>
4 4  
  5 +QPDF_Unresolved::QPDF_Unresolved() :
  6 + QPDFValue(::ot_unresolved, "unresolved")
  7 +{
  8 +}
  9 +
5 10 std::shared_ptr<QPDFObject>
6 11 QPDF_Unresolved::create()
7 12 {
... ... @@ -27,15 +32,3 @@ QPDF_Unresolved::getJSON(int json_version)
27 32 {
28 33 return JSON::makeNull();
29 34 }
30   -
31   -qpdf_object_type_e
32   -QPDF_Unresolved::getTypeCode() const
33   -{
34   - return ::ot_unresolved;
35   -}
36   -
37   -char const*
38   -QPDF_Unresolved::getTypeName() const
39   -{
40   - return "unresolved";
41   -}
... ...
libqpdf/qpdf/QPDF_Array.hh
... ... @@ -17,8 +17,6 @@ class QPDF_Array: public QPDFValue
17 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 18 virtual std::string unparse();
19 19 virtual JSON getJSON(int json_version);
20   - virtual qpdf_object_type_e getTypeCode() const;
21   - virtual char const* getTypeName() const;
22 20  
23 21 int getNItems() const;
24 22 QPDFObjectHandle getItem(int n) const;
... ...
libqpdf/qpdf/QPDF_Bool.hh
... ... @@ -11,8 +11,6 @@ class QPDF_Bool: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14 bool getVal() const;
17 15  
18 16 private:
... ...
libqpdf/qpdf/QPDF_Dictionary.hh
... ... @@ -17,8 +17,6 @@ class QPDF_Dictionary: public QPDFValue
17 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 18 virtual std::string unparse();
19 19 virtual JSON getJSON(int json_version);
20   - virtual qpdf_object_type_e getTypeCode() const;
21   - virtual char const* getTypeName() const;
22 20  
23 21 // hasKey() and getKeys() treat keys with null values as if they
24 22 // aren't there. getKey() returns null for the value of a
... ...
libqpdf/qpdf/QPDF_InlineImage.hh
... ... @@ -11,8 +11,6 @@ class QPDF_InlineImage: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14 std::string getVal() const;
17 15  
18 16 private:
... ...
libqpdf/qpdf/QPDF_Integer.hh
... ... @@ -11,8 +11,6 @@ class QPDF_Integer: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14 long long getVal() const;
17 15  
18 16 private:
... ...
libqpdf/qpdf/QPDF_Name.hh
... ... @@ -11,8 +11,6 @@ class QPDF_Name: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14 std::string getName() const;
17 15  
18 16 // Put # into strings with characters unsuitable for name token
... ...
libqpdf/qpdf/QPDF_Null.hh
... ... @@ -11,11 +11,9 @@ class QPDF_Null: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14  
17 15 private:
18   - QPDF_Null() = default;
  16 + QPDF_Null();
19 17 };
20 18  
21 19 #endif // QPDF_NULL_HH
... ...
libqpdf/qpdf/QPDF_Operator.hh
... ... @@ -11,8 +11,6 @@ class QPDF_Operator: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14 std::string getVal() const;
17 15  
18 16 private:
... ...
libqpdf/qpdf/QPDF_Real.hh
... ... @@ -13,8 +13,6 @@ class QPDF_Real: public QPDFValue
13 13 virtual std::shared_ptr<QPDFObject> shallowCopy();
14 14 virtual std::string unparse();
15 15 virtual JSON getJSON(int json_version);
16   - virtual qpdf_object_type_e getTypeCode() const;
17   - virtual char const* getTypeName() const;
18 16 std::string getVal();
19 17  
20 18 private:
... ...
libqpdf/qpdf/QPDF_Reserved.hh
... ... @@ -11,11 +11,9 @@ class QPDF_Reserved: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14  
17 15 private:
18   - QPDF_Reserved() = default;
  16 + QPDF_Reserved();
19 17 };
20 18  
21 19 #endif // QPDF_RESERVED_HH
... ...
libqpdf/qpdf/QPDF_Stream.hh
... ... @@ -26,8 +26,6 @@ class QPDF_Stream: public QPDFValue
26 26 virtual std::shared_ptr<QPDFObject> shallowCopy();
27 27 virtual std::string unparse();
28 28 virtual JSON getJSON(int json_version);
29   - virtual qpdf_object_type_e getTypeCode() const;
30   - virtual char const* getTypeName() const;
31 29 virtual void setDescription(QPDF*, std::string const&);
32 30 QPDFObjectHandle getDict() const;
33 31 bool isDataModified() const;
... ...
libqpdf/qpdf/QPDF_String.hh
... ... @@ -16,8 +16,6 @@ class QPDF_String: public QPDFValue
16 16 create_utf16(std::string const& utf8_val);
17 17 virtual std::shared_ptr<QPDFObject> shallowCopy();
18 18 virtual std::string unparse();
19   - virtual qpdf_object_type_e getTypeCode() const;
20   - virtual char const* getTypeName() const;
21 19 std::string unparse(bool force_binary);
22 20 virtual JSON getJSON(int json_version);
23 21 std::string getVal() const;
... ...
libqpdf/qpdf/QPDF_Unresolved.hh
... ... @@ -11,11 +11,9 @@ class QPDF_Unresolved: public QPDFValue
11 11 virtual std::shared_ptr<QPDFObject> shallowCopy();
12 12 virtual std::string unparse();
13 13 virtual JSON getJSON(int json_version);
14   - virtual qpdf_object_type_e getTypeCode() const;
15   - virtual char const* getTypeName() const;
16 14  
17 15 private:
18   - QPDF_Unresolved() = default;
  16 + QPDF_Unresolved();
19 17 };
20 18  
21 19 #endif // QPDF_UNRESOLVED_HH
... ...