summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/TextString.h
blob: 909d325909783cc0cf25e5a9657612efca8624a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//========================================================================
//
// TextString.h
//
// Copyright 2011-2013 Glyph & Cog, LLC
//
// Represents a PDF "text string", which can either be a UTF-16BE
// string (with a leading byte order marker), or an 8-bit string in
// PDFDocEncoding.
//
//========================================================================

#ifndef TEXTSTRING_H
#define TEXTSTRING_H

#include <aconf.h>

#include "CharTypes.h"

class GString;

//------------------------------------------------------------------------

class TextString {
public:

  // Create an empty TextString.
  TextString();

  // Create a TextString from a PDF text string.
  TextString(GString *s);

  // Copy a TextString.
  TextString(TextString *s);

  ~TextString();

  // Append a Unicode character or PDF text string to this TextString.
  TextString *append(Unicode c);
  TextString *append(GString *s);

  // Insert a Unicode character, sequence of Unicode characters, or
  // PDF text string in this TextString.
  TextString *insert(int idx, Unicode c);
  TextString *insert(int idx, Unicode *u2, int n);
  TextString *insert(int idx, GString *s);

  // Get the Unicode characters in the TextString.
  int getLength() { return len; }
  Unicode *getUnicode() { return u; }

  // Create a PDF text string from a TextString.
  GString *toPDFTextString();

  // Convert a TextString to UTF-8.
  GString *toUTF8();

private:

  void expand(int delta);

  Unicode *u;			// NB: not null-terminated
  int len;
  int size;
};

#endif