1This is autosprintf.info, produced by makeinfo version 4.8 from
2autosprintf.texi.
3
4INFO-DIR-SECTION C++ libraries
5START-INFO-DIR-ENTRY
6* autosprintf: (autosprintf).   Support for printf format strings in C++.
7END-INFO-DIR-ENTRY
8
9   This file provides documentation for GNU `autosprintf' library.
10
11   Copyright (C) 2002-2003 Free Software Foundation, Inc.
12
13   This manual is free documentation.  It is dually licensed under the
14GNU FDL and the GNU GPL.  This means that you can redistribute this
15manual under either of these two licenses, at your choice.
16
17   This manual is covered by the GNU FDL.  Permission is granted to
18copy, distribute and/or modify this document under the terms of the GNU
19Free Documentation License (FDL), either version 1.2 of the License, or
20(at your option) any later version published by the Free Software
21Foundation (FSF); with no Invariant Sections, with no Front-Cover Text,
22and with no Back-Cover Texts.  A copy of the license is at
23`http://www.gnu.org/licenses/fdl.html'.
24
25   This manual is covered by the GNU GPL.  You can redistribute it
26and/or modify it under the terms of the GNU General Public License
27(GPL), either version 2 of the License, or (at your option) any later
28version published by the Free Software Foundation (FSF).  A copy of the
29license is at `http://www.gnu.org/licenses/gpl.html'.
30
31
32File: autosprintf.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
33
34GNU autosprintf
35***************
36
37This manual documents the GNU autosprintf class, version 1.0.
38
39* Menu:
40
41* Introduction::                Introduction
42* Class autosprintf::           The `autosprintf' class
43* Using autosprintf::           Using `autosprintf' in own programs
44
45
46File: autosprintf.info,  Node: Introduction,  Next: Class autosprintf,  Prev: Top,  Up: Top
47
481 Introduction
49**************
50
51This package makes the C formatted output routines (`fprintf' et al.)
52usable in C++ programs, for use with the `<string>' strings and the
53`<iostream>' streams.
54
55   It allows to write code like
56
57     cerr << autosprintf ("syntax error in %s:%d: %s", filename, line, errstring);
58
59instead of
60
61     cerr << "syntax error in " << filename << ":" << line << ": " << errstring;
62
63   The benefits of the autosprintf syntax are:
64
65   * It reuses the standard POSIX printf facility. Easy migration from
66     C to C++.
67
68   * English sentences are kept together.
69
70   * It makes internationalization possible. Internationalization
71     requires format strings, because in some cases the translator
72     needs to change the order of a sentence, and more generally it is
73     easier for the translator to work with a single string for a
74     sentence than with multiple string pieces.
75
76   * It reduces the risk of programming errors due to forgotten state
77     in the output stream (e.g. `cout << hex;' not followed by `cout <<
78     dec;').
79
80
81File: autosprintf.info,  Node: Class autosprintf,  Next: Using autosprintf,  Prev: Introduction,  Up: Top
82
832 The `autosprintf' class
84*************************
85
86An instance of class `autosprintf' just contains a string with the
87formatted output result. Such an instance is usually allocated as an
88automatic storage variable, i.e. on the stack, not with `new' on the
89heap.
90
91   The constructor `autosprintf (const char *format, ...)' takes a
92format string and additional arguments, like the C function `printf'.
93
94   Conversions to `char *' and `std::string' are defined that return
95the encapsulated string.
96
97   The destructor `~autosprintf ()' destroys the encapsulated string.
98
99   An `operator <<' is provided that outputs the encapsulated string to
100the given `ostream'.
101
102
103File: autosprintf.info,  Node: Using autosprintf,  Prev: Class autosprintf,  Up: Top
104
1053 Using `autosprintf' in own programs
106*************************************
107
108To use the `autosprintf' class in your programs, you need to add
109
110     #include "autosprintf.h"
111     using gnu::autosprintf;
112
113to your source code.  The include file defines the class `autosprintf',
114in a namespace called `gnu'. The `using' statement makes it possible to
115use the class without the (otherwise natural) `gnu::' prefix.
116
117   When linking your program, you need to link with `libasprintf',
118because that's where the class is defined. In projects using GNU
119`autoconf', this means adding `AC_LIB_LINKFLAGS([asprintf])' to
120`configure.in' or `configure.ac', and using the @LIBASPRINTF@ Makefile
121variable that it provides.
122
123
124
125Tag Table:
126Node: Top1336
127Node: Introduction1696
128Node: Class autosprintf2847
129Node: Using autosprintf3619
130
131End Tag Table
132