/src/xpdf-4.05/xpdf/TextString.h
Line | Count | Source (jump to first uncovered line) |
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 | | #include "CharTypes.h" |
19 | | |
20 | | class GString; |
21 | | |
22 | | //------------------------------------------------------------------------ |
23 | | |
24 | | class TextString { |
25 | | public: |
26 | | |
27 | | // Create an empty TextString. |
28 | | TextString(); |
29 | | |
30 | | // Create a TextString from a PDF text string. |
31 | | TextString(GString *s); |
32 | | |
33 | | // Copy a TextString. |
34 | | TextString(TextString *s); |
35 | | |
36 | | ~TextString(); |
37 | | |
38 | | // Append a Unicode character or PDF text string to this TextString. |
39 | | TextString *append(Unicode c); |
40 | | TextString *append(GString *s); |
41 | | |
42 | | // Insert a Unicode character, sequence of Unicode characters, or |
43 | | // PDF text string in this TextString. |
44 | | TextString *insert(int idx, Unicode c); |
45 | | TextString *insert(int idx, Unicode *u2, int n); |
46 | | TextString *insert(int idx, GString *s); |
47 | | |
48 | | // Get the Unicode characters in the TextString. |
49 | 28.7k | int getLength() { return len; } |
50 | 0 | Unicode *getUnicode() { return u; } |
51 | | |
52 | | // Create a PDF text string from a TextString. |
53 | | GString *toPDFTextString(); |
54 | | |
55 | | // Convert a TextString to UTF-8. |
56 | | GString *toUTF8(); |
57 | | |
58 | | private: |
59 | | |
60 | | void expand(int delta); |
61 | | |
62 | | Unicode *u; // NB: not null-terminated |
63 | | int len; |
64 | | int size; |
65 | | }; |
66 | | |
67 | | #endif |