00001
00002
00003
00004
00005
00006 #ifndef H_CPPSDFObj
00007 #define H_CPPSDFObj
00008
00009 #include <Common/Exception.h>
00010 #include <Common/UString.h>
00011 #include <Common/Matrix2D.h>
00012 #include <Filters/FilterWriter.h>
00013 #include <Filters/Filter.h>
00014
00015
00016 namespace pdftron {
00017 namespace SDF {
00018
00019 class DictIterator;
00020
00041 class Obj
00042 {
00043 public:
00044
00045
00046
00050 enum Type
00051 {
00052 e_null,
00053 e_bool,
00054 e_number,
00055 e_name,
00056 e_string,
00057 e_dict,
00058 e_array,
00059 e_stream
00060 };
00061
00066 Type GetType () const;
00067
00072 bool IsBool () const;
00073
00078 bool IsNumber () const;
00079
00084 bool IsNull () const;
00085
00090 bool IsString () const;
00091
00096 bool IsName () const;
00097
00103 bool IsIndirect () const;
00104
00110 bool IsContainer () const;
00111
00116 bool IsDict () const;
00117
00122 bool IsArray () const;
00123
00128 bool IsStream () const;
00129
00134 class SDFDoc& GetDoc () const;
00135
00141 void Write(Filters::FilterWriter& stream);
00142
00156 ULong Size () const;
00157
00158
00159
00165 ULong GetObjNum () const;
00166
00172 UShort GetGenNum () const;
00173
00179 ULong GetOffset () const;
00180
00185 bool IsFree () const;
00186
00193 void SetMark (bool mark);
00194
00199 bool IsMarked () const;
00200
00205 bool IsLoaded () const;
00206
00207
00208
00209
00214 bool GetBool () const;
00215
00220 void SetBool (bool b);
00221
00222
00223
00228 double GetNumber () const;
00229
00234 void SetNumber (double n);
00235
00236
00237
00238
00253 const UChar* GetBuffer () const;
00254
00270 void GetAsPDFText(UString& out_str) const;
00271
00279 void SetString(const UChar* value, UInt size);
00280
00286 void SetString(const UString& str);
00287
00288
00289
00294 const char* GetName () const;
00295
00300 void SetName (const char* name);
00301
00302
00303
00304
00321 DictIterator GetDictIterator ();
00322
00343 DictIterator Find (const char* key);
00344
00354 Obj FindObj (const char* key);
00355
00365 DictIterator Get (const char* key);
00366
00379 Obj PutName (const char* key, const char* name);
00380
00392 Obj PutArray (const char* key);
00393
00406 Obj PutBool (const char* key, bool value);
00407
00418 Obj PutDict (const char* key);
00419
00432 Obj PutNumber (const char* key, double value);
00433
00446 Obj PutString (const char* key, const char* value);
00447
00461 Obj PutString (const char* key, const char* value, int size);
00462
00476 Obj PutText(const char* key, const UString& value);
00477
00484 void PutNull (const char* key);
00485
00495 Obj Put(const char* key, Obj obj);
00496
00509 Obj PutRect (const char* key, double x1, double y1, double x2, double y2);
00510
00523 Obj PutMatrix(const char* key, const Common::Matrix2D& value);
00524
00529 void Erase (const char* key);
00530
00535 void Erase (DictIterator pos);
00536
00544 bool Rename (const char* old_key, const char* new_key);
00545
00546
00547
00548
00555 Obj GetAt (UInt index) const;
00556
00568 Obj InsertName (UInt pos, const char* name);
00569
00580 Obj InsertArray (UInt pos);
00581
00593 Obj InsertBool (UInt pos, bool value);
00594
00605 Obj InsertDict (UInt pos);
00606
00618 Obj InsertNumber (UInt pos, double value);
00619
00631 Obj InsertString (UInt pos, const char* value);
00632
00646 Obj InsertString (UInt pos, const char* value, int size);
00647
00660 Obj InsertText(UInt pos, const UString& value);
00661
00670 Obj InsertNull(UInt pos);
00671
00683 Obj Insert(UInt pos, Obj obj);
00684
00696 Obj InsertRect (UInt pos, double x1, double y1, double x2, double y2);
00697
00709 Obj InsertMatrix(UInt pos, Common::Matrix2D& value);
00710
00717 Obj PushBackName (const char* name);
00718
00724 Obj PushBackArray ();
00725
00732 Obj PushBackBool (bool value);
00733
00739 Obj PushBackDict ();
00740
00747 Obj PushBackNumber (double value);
00748
00755 Obj PushBackString (const char* value);
00756
00765 Obj PushBackString (const char* value, int size);
00766
00774 Obj PushBackText (const UString& value);
00775
00781 Obj PushBackNull ();
00782
00791 Obj PushBack(Obj obj);
00792
00800 Obj PushBackRect (double x1, double y1, double x2, double y2);
00801
00809 Obj PushBackMatrix(Common::Matrix2D& value);
00810
00820 void EraseAt (UInt pos);
00821
00822
00823
00824
00829 ULong GetRawStreamLength () const;
00830
00836 Filters::Filter GetRawStream (bool decrypt) const;
00837
00842 Filters::Filter GetDecodedStream () const;
00843
00844
00845
00846
00847 Obj() : mp_obj(0) {}
00848 Obj(const Obj& c) : mp_obj(c.mp_obj) {}
00849 Obj& operator=(const Obj& c) {mp_obj=c.mp_obj; return *this;}
00850
00854 operator bool () { return mp_obj!=0;}
00855
00862 bool IsEqual(const Obj& to) const;
00863 bool operator ==(const Obj& to) const;
00864
00866 Obj(TRN_Obj impl);
00867 TRN_Obj mp_obj;
00868 private:
00869 mutable TRN_SDFDoc temp_doc;
00871 };
00872
00873
00874
00875 };
00876 };
00877
00878
00879
00880 #include <Impl/SDFDoc.inl>
00881 #endif
00882