Loading...
Searching...
No Matches
Obj.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5#ifndef PDFTRON_H_CPPSDFSDFObj
6#define PDFTRON_H_CPPSDFSDFObj
7
8#include <Common/Exception.h>
9#include <Common/UString.h>
10#include <Common/Matrix2D.h>
11#include <Filters/FilterWriter.h>
12#include <Filters/Filter.h>
13
14
15 namespace pdftron {
16 namespace SDF {
17
18 class DictIterator;
19
40 class Obj
41{
42 public:
43
44 // Common methods for all objects -----------------------------------------------
45
49 enum Type
50 {
51 e_null,
52 e_bool,
53 e_number,
54 e_name,
55 e_string,
56 e_dict,
57 e_array,
58 e_stream
59 };
60
65 Type GetType () const;
66
71 bool IsBool () const;
72
77 bool IsNumber () const;
78
83 bool IsNull () const;
84
89 bool IsString () const;
90
95 bool IsName () const;
96
102 bool IsIndirect () const;
103
109 bool IsContainer () const;
110
115 bool IsDict () const;
116
121 bool IsArray () const;
122
127 bool IsStream () const;
128
133 class SDFDoc& GetDoc () const;
134
140 void Write(Filters::FilterWriter& stream);
141
155 size_t Size () const;
156
157 // Indirect Methods -------------------------------------------------------------
158
164 UInt32 GetObjNum () const;
165
171 UInt16 GetGenNum () const;
172
178 size_t GetOffset () const;
179
184 bool IsFree () const;
185
193 void SetMark (bool mark);
194
199 bool IsMarked () const;
200
205 bool IsLoaded () const;
206
211 bool IsValid () const;
212
213 // Boolean Specific Methods ----------------------------------------------------
214
219 bool GetBool () const;
220
225 void SetBool (bool b);
226
227 // Number Specific Methods -----------------------------------------------------
228
233 double GetNumber () const;
234
239 void SetNumber (double n);
240
241
242 // String Specific Methods -----------------------------------------------------
243
258#ifdef SWIG
259 std::vector<unsigned char> GetBuffer () const;
260#else
261 const UChar* GetBuffer () const;
262#endif
263
272 std::vector<unsigned char> GetRawBuffer() const;
273
289 UString GetAsPDFText() const;
290
291#ifndef SWIG
292 void GetAsPDFText(UString& out_str) const;
293#endif
294
302 void SetString(const UChar* value, size_t size);
303
309 void SetString(const UString& str);
310
311 // Name Specific Methods -------------------------------------------------------
312
317 const char* GetName () const;
318
323 void SetName (const char* name);
324
325
326 // Dictionary Specific Methods -------------------------------------------------
327
343 DictIterator GetDictIterator ();
344
366 DictIterator Find (const char* key);
367
377 Obj FindObj (const char* key);
378
388 DictIterator Get (const char* key);
389
402 Obj PutName (const char* key, const char* name);
403
415 Obj PutArray (const char* key);
416
429 Obj PutBool (const char* key, bool value);
430
441 Obj PutDict (const char* key);
442
455 Obj PutNumber (const char* key, double value);
456
469 Obj PutString (const char* key, const char* value);
470
484 Obj PutString (const char* key, const char* value, int size);
485
499 Obj PutText(const char* key, const UString& value);
500
507 void PutNull (const char* key);
508
518 Obj Put(const char* key, Obj obj);
519
534 Obj PutRect (const char* key, double x1, double y1, double x2, double y2);
535
548 Obj PutMatrix(const char* key, const Common::Matrix2D& value);
549
555 void Erase (const char* key);
556
562 void Erase (DictIterator pos);
563
572 bool Rename (const char* old_key, const char* new_key);
573
574
575 // Array Specific Methods ------------------------------------------------------
576
583 Obj GetAt (size_t index) const;
584
596 Obj InsertName (size_t pos, const char* name);
597
608 Obj InsertArray (size_t pos);
609
621 Obj InsertBool (size_t pos, bool value);
622
633 Obj InsertDict (size_t pos);
634
646 Obj InsertNumber (size_t pos, double value);
647
659 Obj InsertString (size_t pos, const char* value);
660
674 Obj InsertString (size_t pos, const char* value, int size);
675
688 Obj InsertText(size_t pos, const UString& value);
689
698 Obj InsertNull(size_t pos);
699
711 Obj Insert(size_t pos, Obj obj);
712
726 Obj InsertRect (size_t pos, double x1, double y1, double x2, double y2);
727
739 Obj InsertMatrix(size_t pos, const Common::Matrix2D& value);
740
747 Obj PushBackName (const char* name);
748
754 Obj PushBackArray ();
755
762 Obj PushBackBool (bool value);
763
769 Obj PushBackDict ();
770
777 Obj PushBackNumber (double value);
778
785 Obj PushBackString (const char* value);
786
795 Obj PushBackString (const char* value, int size);
796
804 Obj PushBackText (const UString& value);
805
811 Obj PushBackNull ();
812
821 Obj PushBack(Obj obj);
822
832 Obj PushBackRect (double x1, double y1, double x2, double y2);
833
841 Obj PushBackMatrix(const Common::Matrix2D& value);
842
852 void EraseAt (size_t pos);
853
854
855 // Stream Specific Methods -----------------------------------------------------
856
861 size_t GetRawStreamLength () const;
862
868 Filters::Filter GetRawStream (bool decrypt) const;
869
874 Filters::Filter GetDecodedStream () const;
875
880#ifndef SWIG
881 void SetStreamData(
882 const char* data,
883 const size_t data_size,
884 Filters::Filter filter_chain = Filters::Filter() );
885#endif
886 void SetStreamData( const std::vector<unsigned char>& data,
887 Filters::Filter filter_chain = Filters::Filter() );
888
889
890 // Support methods ----------------------------------------------------------------
891
892 Obj() : mp_obj(0) {}
893 Obj(const Obj& c) : mp_obj(c.mp_obj) {}
894 Obj& operator=(const Obj& c) {mp_obj=c.mp_obj; return *this;}
895
899 operator bool () { return mp_obj!=0;}
900
907 bool IsEqual(const Obj& to) const;
908 bool operator ==(const Obj& to) const;
909 bool operator <(const Obj& to) const { return mp_obj < to.mp_obj; }
910
911 //for xamarin use only
912 static Obj* CreateInternal(ptrdiff_t impl);
913 ptrdiff_t GetHandleInternal();
914
915 // @cond PRIVATE_DOC
916 #ifndef SWIGHIDDEN
917 Obj(TRN_Obj impl);
918 TRN_Obj mp_obj;
919 private:
920 mutable TRN_SDFDoc temp_doc;
921 #endif
922 // @endcond
923};
924
925
926
927 }; // namespace SDF
928}; // namespace pdftron
929
930
931
932#include <Impl/SDFDoc.inl>
933
934#endif // PDFTRON_H_CPPSDFSDFObj
Exception.h
Filter.h
FilterWriter.h
Matrix2D.h
UString.h
pdftron::Common::Matrix2D
Definition Matrix2D.h:104
pdftron::Filters::Filter
Definition Filter.h:46
pdftron::Filters::FilterWriter
Definition FilterWriter.h:30
pdftron::SDF::DictIterator
Definition DictIterator.h:33
pdftron::SDF::Obj::PutRect
Obj PutRect(const char *key, double x1, double y1, double x2, double y2)
pdftron::SDF::Obj::InsertArray
Obj InsertArray(size_t pos)
pdftron::SDF::Obj::CreateInternal
static Obj * CreateInternal(ptrdiff_t impl)
pdftron::SDF::Obj::InsertString
Obj InsertString(size_t pos, const char *value, int size)
pdftron::SDF::Obj::Type
Type
Definition Obj.h:50
pdftron::SDF::Obj::e_array
@ e_array
Definition Obj.h:57
pdftron::SDF::Obj::e_string
@ e_string
Definition Obj.h:55
pdftron::SDF::Obj::e_name
@ e_name
Definition Obj.h:54
pdftron::SDF::Obj::e_dict
@ e_dict
Definition Obj.h:56
pdftron::SDF::Obj::e_stream
@ e_stream
Definition Obj.h:58
pdftron::SDF::Obj::e_null
@ e_null
Definition Obj.h:51
pdftron::SDF::Obj::e_bool
@ e_bool
Definition Obj.h:52
pdftron::SDF::Obj::e_number
@ e_number
Definition Obj.h:53
pdftron::SDF::Obj::PushBackArray
Obj PushBackArray()
pdftron::SDF::Obj::Find
DictIterator Find(const char *key)
pdftron::SDF::Obj::PushBackText
Obj PushBackText(const UString &value)
pdftron::SDF::Obj::FindObj
Obj FindObj(const char *key)
pdftron::SDF::Obj::GetGenNum
UInt16 GetGenNum() const
pdftron::SDF::Obj::GetDecodedStream
Filters::Filter GetDecodedStream() const
pdftron::SDF::Obj::SetString
void SetString(const UChar *value, size_t size)
pdftron::SDF::Obj::IsFree
bool IsFree() const
pdftron::SDF::Obj::PutDict
Obj PutDict(const char *key)
pdftron::SDF::Obj::PutBool
Obj PutBool(const char *key, bool value)
pdftron::SDF::Obj::SetString
void SetString(const UString &str)
pdftron::SDF::Obj::Insert
Obj Insert(size_t pos, Obj obj)
pdftron::SDF::Obj::GetNumber
double GetNumber() const
pdftron::SDF::Obj::Obj
Obj()
Definition Obj.h:892
pdftron::SDF::Obj::InsertMatrix
Obj InsertMatrix(size_t pos, const Common::Matrix2D &value)
pdftron::SDF::Obj::InsertString
Obj InsertString(size_t pos, const char *value)
pdftron::SDF::Obj::PushBackString
Obj PushBackString(const char *value, int size)
pdftron::SDF::Obj::IsLoaded
bool IsLoaded() const
pdftron::SDF::Obj::PushBack
Obj PushBack(Obj obj)
pdftron::SDF::Obj::IsBool
bool IsBool() const
pdftron::SDF::Obj::GetName
const char * GetName() const
pdftron::SDF::Obj::PushBackMatrix
Obj PushBackMatrix(const Common::Matrix2D &value)
pdftron::SDF::Obj::GetRawStream
Filters::Filter GetRawStream(bool decrypt) const
pdftron::SDF::Obj::PutNumber
Obj PutNumber(const char *key, double value)
pdftron::SDF::Obj::operator=
Obj & operator=(const Obj &c)
Definition Obj.h:894
pdftron::SDF::Obj::PushBackName
Obj PushBackName(const char *name)
pdftron::SDF::Obj::Get
DictIterator Get(const char *key)
pdftron::SDF::Obj::GetRawStreamLength
size_t GetRawStreamLength() const
pdftron::SDF::Obj::PutName
Obj PutName(const char *key, const char *name)
pdftron::SDF::Obj::Erase
void Erase(DictIterator pos)
pdftron::SDF::Obj::SetBool
void SetBool(bool b)
pdftron::SDF::Obj::PushBackBool
Obj PushBackBool(bool value)
pdftron::SDF::Obj::SetName
void SetName(const char *name)
pdftron::SDF::Obj::InsertName
Obj InsertName(size_t pos, const char *name)
pdftron::SDF::Obj::PushBackNumber
Obj PushBackNumber(double value)
pdftron::SDF::Obj::IsStream
bool IsStream() const
pdftron::SDF::Obj::IsArray
bool IsArray() const
pdftron::SDF::Obj::operator==
bool operator==(const Obj &to) const
pdftron::SDF::Obj::GetType
Type GetType() const
pdftron::SDF::Obj::InsertRect
Obj InsertRect(size_t pos, double x1, double y1, double x2, double y2)
pdftron::SDF::Obj::PutMatrix
Obj PutMatrix(const char *key, const Common::Matrix2D &value)
pdftron::SDF::Obj::InsertNull
Obj InsertNull(size_t pos)
pdftron::SDF::Obj::PushBackRect
Obj PushBackRect(double x1, double y1, double x2, double y2)
pdftron::SDF::Obj::IsNull
bool IsNull() const
pdftron::SDF::Obj::GetObjNum
UInt32 GetObjNum() const
pdftron::SDF::Obj::GetOffset
size_t GetOffset() const
pdftron::SDF::Obj::InsertDict
Obj InsertDict(size_t pos)
pdftron::SDF::Obj::IsContainer
bool IsContainer() const
pdftron::SDF::Obj::GetHandleInternal
ptrdiff_t GetHandleInternal()
pdftron::SDF::Obj::IsValid
bool IsValid() const
pdftron::SDF::Obj::Rename
bool Rename(const char *old_key, const char *new_key)
pdftron::SDF::Obj::Erase
void Erase(const char *key)
pdftron::SDF::Obj::SetNumber
void SetNumber(double n)
pdftron::SDF::Obj::IsDict
bool IsDict() const
pdftron::SDF::Obj::IsEqual
bool IsEqual(const Obj &to) const
pdftron::SDF::Obj::IsName
bool IsName() const
pdftron::SDF::Obj::operator<
bool operator<(const Obj &to) const
Definition Obj.h:909
pdftron::SDF::Obj::SetStreamData
void SetStreamData(const char *data, const size_t data_size, Filters::Filter filter_chain=Filters::Filter())
pdftron::SDF::Obj::Write
void Write(Filters::FilterWriter &stream)
pdftron::SDF::Obj::Size
size_t Size() const
pdftron::SDF::Obj::IsIndirect
bool IsIndirect() const
pdftron::SDF::Obj::Obj
Obj(const Obj &c)
Definition Obj.h:893
pdftron::SDF::Obj::PushBackNull
Obj PushBackNull()
pdftron::SDF::Obj::GetDictIterator
DictIterator GetDictIterator()
pdftron::SDF::Obj::PutNull
void PutNull(const char *key)
pdftron::SDF::Obj::PushBackDict
Obj PushBackDict()
pdftron::SDF::Obj::GetAsPDFText
UString GetAsPDFText() const
pdftron::SDF::Obj::PutString
Obj PutString(const char *key, const char *value, int size)
pdftron::SDF::Obj::IsString
bool IsString() const
pdftron::SDF::Obj::GetRawBuffer
std::vector< unsigned char > GetRawBuffer() const
pdftron::SDF::Obj::GetDoc
class SDFDoc & GetDoc() const
pdftron::SDF::Obj::Put
Obj Put(const char *key, Obj obj)
pdftron::SDF::Obj::PutArray
Obj PutArray(const char *key)
pdftron::SDF::Obj::IsNumber
bool IsNumber() const
pdftron::SDF::Obj::PutString
Obj PutString(const char *key, const char *value)
pdftron::SDF::Obj::InsertNumber
Obj InsertNumber(size_t pos, double value)
pdftron::SDF::Obj::SetMark
void SetMark(bool mark)
pdftron::SDF::Obj::GetAsPDFText
void GetAsPDFText(UString &out_str) const
pdftron::SDF::Obj::InsertText
Obj InsertText(size_t pos, const UString &value)
pdftron::SDF::Obj::PutText
Obj PutText(const char *key, const UString &value)
pdftron::SDF::Obj::SetStreamData
void SetStreamData(const std::vector< unsigned char > &data, Filters::Filter filter_chain=Filters::Filter())
pdftron::SDF::Obj::EraseAt
void EraseAt(size_t pos)
pdftron::SDF::Obj::PushBackString
Obj PushBackString(const char *value)
pdftron::SDF::Obj::GetBuffer
const UChar * GetBuffer() const
pdftron::SDF::Obj::InsertBool
Obj InsertBool(size_t pos, bool value)
pdftron::SDF::Obj::GetBool
bool GetBool() const
pdftron::SDF::Obj::GetAt
Obj GetAt(size_t index) const
pdftron::SDF::Obj::IsMarked
bool IsMarked() const
pdftron::SDF::SDFDoc
Definition SDFDoc.h:68
pdftron::UString
Definition UString.h:28
pdftron::SDF
Definition DictIterator.h:12
pdftron
Definition BasicTypes.h:10
pdftron::UInt32
TRN_UInt32 UInt32
Definition BasicTypes.h:13
pdftron::UChar
TRN_UChar UChar
Definition BasicTypes.h:12
pdftron::UInt16
TRN_UInt16 UInt16
Definition BasicTypes.h:14