~ubuntu-branches/ubuntu/lucid/xpdf/lucid-updates

« back to all changes in this revision

Viewing changes to goo/GString.h

  • Committer: Bazaar Package Importer
  • Author(s): Andy Price
  • Date: 2007-05-17 22:04:33 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517220433-gzcx2lrvllkbl7mr
Tags: 3.02-1ubuntu1
* Merge from Debian unstable (LP: #113365), remaining changes:
  - Added back 09_xpdfrc_manpage.dpatch (LP #71753)
  - Set Ubuntu maintainer

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#pragma interface
18
18
#endif
19
19
 
 
20
#include <stdarg.h>
 
21
#include "gtypes.h"
 
22
 
20
23
class GString {
21
24
public:
22
25
 
43
46
  // Convert an integer to a string.
44
47
  static GString *fromInt(int x);
45
48
 
 
49
  // Create a formatted string.  Similar to printf, but without the
 
50
  // string overflow issues.  Formatting elements consist of:
 
51
  //     {<arg>:[<width>][.<precision>]<type>}
 
52
  // where:
 
53
  // - <arg> is the argument number (arg 0 is the first argument
 
54
  //   following the format string) -- NB: args must be first used in
 
55
  //   order; they can be reused in any order
 
56
  // - <width> is the field width -- negative to reverse the alignment;
 
57
  //   starting with a leading zero to zero-fill (for integers)
 
58
  // - <precision> is the number of digits to the right of the decimal
 
59
  //   point (for floating point numbers)
 
60
  // - <type> is one of:
 
61
  //     d, x, o, b -- int in decimal, hex, octal, binary
 
62
  //     ud, ux, uo, ub -- unsigned int
 
63
  //     ld, lx, lo, lb, uld, ulx, ulo, ulb -- long, unsigned long
 
64
  //     f, g -- double
 
65
  //     c -- char
 
66
  //     s -- string (char *)
 
67
  //     t -- GString *
 
68
  //     w -- blank space; arg determines width
 
69
  // To get literal curly braces, use {{ or }}.
 
70
  static GString *format(char *fmt, ...);
 
71
  static GString *formatv(char *fmt, va_list argList);
 
72
 
46
73
  // Destructor.
47
74
  ~GString();
48
75
 
67
94
  GString *append(const char *str);
68
95
  GString *append(const char *str, int lengthA);
69
96
 
 
97
  // Append a formatted string.
 
98
  GString *appendf(char *fmt, ...);
 
99
  GString *appendfv(char *fmt, va_list argList);
 
100
 
70
101
  // Insert a character or string.
71
102
  GString *insert(int i, char c);
72
103
  GString *insert(int i, GString *str);
92
123
  char *s;
93
124
 
94
125
  void resize(int length1);
 
126
  static void formatInt(long x, char *buf, int bufSize,
 
127
                        GBool zeroFill, int width, int base,
 
128
                        char **p, int *len);
 
129
  static void formatUInt(Gulong x, char *buf, int bufSize,
 
130
                         GBool zeroFill, int width, int base,
 
131
                         char **p, int *len);
 
132
  static void formatDouble(double x, char *buf, int bufSize, int prec,
 
133
                           GBool trim, char **p, int *len);
95
134
};
96
135
 
97
136
#endif