1 //======================================================================== 2 // 3 // TextString.h 4 // 5 // Copyright 2011-2013 Glyph & Cog, LLC 6 // 7 // Represents a PDF "text string", which can either be a UTF-16BE 8 // string (with a leading byte order marker), or an 8-bit string in 9 // PDFDocEncoding. 10 // 11 //======================================================================== 12 13 #ifndef TEXTSTRING_H 14 #define TEXTSTRING_H 15 16 #include <aconf.h> 17 18 #ifdef USE_GCC_PRAGMAS 19 #pragma interface 20 #endif 21 22 #include "CharTypes.h" 23 24 class GString; 25 26 //------------------------------------------------------------------------ 27 28 class TextString { 29 public: 30 31 // Create an empty TextString. 32 TextString(); 33 34 // Create a TextString from a PDF text string. 35 TextString(GString *s); 36 37 // Copy a TextString. 38 TextString(TextString *s); 39 40 ~TextString(); 41 42 // Append a Unicode character or PDF text string to this TextString. 43 TextString *append(Unicode c); 44 TextString *append(GString *s); 45 46 // Insert a Unicode character or PDF text string in this TextString. 47 TextString *insert(int idx, Unicode c); 48 TextString *insert(int idx, GString *s); 49 50 // Get the Unicode characters in the TextString. getLength()51 int getLength() { return len; } getUnicode()52 Unicode *getUnicode() { return u; } 53 54 // Create a PDF text string from a TextString. 55 GString *toPDFTextString(); 56 57 private: 58 59 void expand(int delta); 60 61 Unicode *u; // NB: not null-terminated 62 int len; 63 int size; 64 }; 65 66 #endif 67