~ubuntu-branches/ubuntu/breezy/gettext/breezy

« back to all changes in this revision

Viewing changes to gettext-runtime/libasprintf/autosprintf.info

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2004-03-14 17:40:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314174002-p1ad5ldve1hqzhye
Tags: 0.14.1-2
* Added libexpat1-dev to Build-Depends, for glade support.
* Added libc0.1-dev to Build-Depends, for GNU/kFreeBSD.
* Removed special-casing of knetbsd-gnu in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
This is autosprintf.info, produced by makeinfo version 4.6 from
 
2
autosprintf.texi.
 
3
 
 
4
INFO-DIR-SECTION C++ libraries
 
5
START-INFO-DIR-ENTRY
 
6
* autosprintf: (autosprintf).   Support for printf format strings in C++.
 
7
END-INFO-DIR-ENTRY
 
8
 
 
9
   This file provides documentation for GNU `autosprintf' library.
 
10
 
 
11
   Copyright (C) 2002 Free Software Foundation, Inc.
 
12
 
 
13
   Permission is granted to make and distribute verbatim copies of this
 
14
manual provided the copyright notice and this permission notice are
 
15
preserved on all copies.
 
16
 
 
17
   Permission is granted to copy and distribute modified versions of
 
18
this manual under the conditions for verbatim copying, provided that
 
19
the entire resulting derived work is distributed under the terms of a
 
20
permission notice identical to this one.
 
21
 
 
22
   Permission is granted to copy and distribute translations of this
 
23
manual into another language, under the above conditions for modified
 
24
versions, except that this permission notice may be stated in a
 
25
translation approved by the Foundation.
 
26
 
 
27
 
 
28
File: autosprintf.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
 
29
 
 
30
GNU autosprintf
 
31
***************
 
32
 
 
33
This manual documents the GNU autosprintf class, version 1.0.
 
34
 
 
35
* Menu:
 
36
 
 
37
* Introduction::                Introduction
 
38
* Class autosprintf::           The `autosprintf' class
 
39
* Using autosprintf::           Using `autosprintf' in own programs
 
40
 
 
41
 
 
42
File: autosprintf.info,  Node: Introduction,  Next: Class autosprintf,  Prev: Top,  Up: Top
 
43
 
 
44
Introduction
 
45
************
 
46
 
 
47
This package makes the C formatted output routines (`fprintf' et al.)
 
48
usable in C++ programs, for use with the `<string>' strings and the
 
49
`<iostream>' streams.
 
50
 
 
51
   It allows to write code like
 
52
 
 
53
     cerr << autosprintf ("syntax error in %s:%d: %s", filename, line, errstring);
 
54
 
 
55
instead of
 
56
 
 
57
     cerr << "syntax error in " << filename << ":" << line << ": " << errstring;
 
58
 
 
59
   The benefits of the autosprintf syntax are:
 
60
 
 
61
   * It reuses the standard POSIX printf facility. Easy migration from
 
62
     C to C++.
 
63
 
 
64
   * English sentences are kept together.
 
65
 
 
66
   * It makes internationalization possible. Internationalization
 
67
     requires format strings, because in some cases the translator
 
68
     needs to change the order of a sentence, and more generally it is
 
69
     easier for the translator to work with a single string for a
 
70
     sentence than with multiple string pieces.
 
71
 
 
72
   * It reduces the risk of programming errors due to forgotten state
 
73
     in the output stream (e.g. `cout << hex;' not followed by `cout <<
 
74
     dec;').
 
75
 
 
76
 
 
77
File: autosprintf.info,  Node: Class autosprintf,  Next: Using autosprintf,  Prev: Introduction,  Up: Top
 
78
 
 
79
The `autosprintf' class
 
80
***********************
 
81
 
 
82
An instance of class `autosprintf' just contains a string with the
 
83
formatted output result. Such an instance is usually allocated as an
 
84
automatic storage variable, i.e. on the stack, not with `new' on the
 
85
heap.
 
86
 
 
87
   The constructor `autosprintf (const char *format, ...)' takes a
 
88
format string and additional arguments, like the C function `printf'.
 
89
 
 
90
   Conversions to `char *' and `std::string' are defined that return
 
91
the encapsulated string.
 
92
 
 
93
   The destructor `~autosprintf ()' destroys the encapsulated string.
 
94
 
 
95
   An `operator <<' is provided that outputs the encapsulated string to
 
96
the given `ostream'.
 
97
 
 
98
 
 
99
File: autosprintf.info,  Node: Using autosprintf,  Prev: Class autosprintf,  Up: Top
 
100
 
 
101
Using `autosprintf' in own programs
 
102
***********************************
 
103
 
 
104
To use the `autosprintf' class in your programs, you need to add
 
105
 
 
106
     #include "autosprintf.h"
 
107
     using gnu::autosprintf;
 
108
 
 
109
to your source code.  The include file defines the class `autosprintf',
 
110
in a namespace called `gnu'. The `using' statement makes it possible to
 
111
use the class without the (otherwise natural) `gnu::' prefix.
 
112
 
 
113
   When linking your program, you need to link with `libasprintf',
 
114
because that's where the class is defined. In projects using GNU
 
115
`autoconf', this means adding `AC_LIB_LINKFLAGS([asprintf])' to
 
116
`configure.in' or `configure.ac', and using the @LIBASPRINTF@ Makefile
 
117
variable that it provides.
 
118
 
 
119
 
 
120
 
 
121
Tag Table:
 
122
Node: Top1011
 
123
Node: Introduction1371
 
124
Node: Class autosprintf2518
 
125
Node: Using autosprintf3286
 
126
 
 
127
End Tag Table