Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / info / autosprintf.info
blob37af0bddb1a149235f2022eccaff6351e2871800
1 This is autosprintf.info, produced by makeinfo version 4.13 from
2 autosprintf.texi.
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
9    This file provides documentation for GNU `autosprintf' library.
11    Copyright (C) 2002-2003, 2006-2007 Free Software Foundation, Inc.
13    This manual is free documentation.  It is dually licensed under the
14 GNU FDL and the GNU GPL.  This means that you can redistribute this
15 manual under either of these two licenses, at your choice.
17    This manual is covered by the GNU FDL.  Permission is granted to
18 copy, distribute and/or modify this document under the terms of the GNU
19 Free Documentation License (FDL), either version 1.2 of the License, or
20 (at your option) any later version published by the Free Software
21 Foundation (FSF); with no Invariant Sections, with no Front-Cover Text,
22 and with no Back-Cover Texts.  A copy of the license is at
23 `http://www.gnu.org/licenses/fdl.html'.
25    This manual is covered by the GNU GPL.  You can redistribute it
26 and/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
28 version published by the Free Software Foundation (FSF).  A copy of the
29 license is at `http://www.gnu.org/licenses/gpl.html'.
31 \x1f
32 File: autosprintf.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
34 GNU autosprintf
35 ***************
37 This manual documents the GNU autosprintf class, version 1.0.
39 * Menu:
41 * Introduction::                Introduction
42 * Class autosprintf::           The `autosprintf' class
43 * Using autosprintf::           Using `autosprintf' in own programs
45 \x1f
46 File: autosprintf.info,  Node: Introduction,  Next: Class autosprintf,  Prev: Top,  Up: Top
48 1 Introduction
49 **************
51 This package makes the C formatted output routines (`fprintf' et al.)
52 usable in C++ programs, for use with the `<string>' strings and the
53 `<iostream>' streams.
55    It allows to write code like
57      cerr << autosprintf ("syntax error in %s:%d: %s", filename, line, errstring);
59 instead of
61      cerr << "syntax error in " << filename << ":" << line << ": " << errstring;
63    The benefits of the autosprintf syntax are:
65    * It reuses the standard POSIX printf facility. Easy migration from
66      C to C++.
68    * English sentences are kept together.
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.
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;').
80 \x1f
81 File: autosprintf.info,  Node: Class autosprintf,  Next: Using autosprintf,  Prev: Introduction,  Up: Top
83 2 The `autosprintf' class
84 *************************
86 An instance of class `autosprintf' just contains a string with the
87 formatted output result. Such an instance is usually allocated as an
88 automatic storage variable, i.e. on the stack, not with `new' on the
89 heap.
91    The constructor `autosprintf (const char *format, ...)' takes a
92 format string and additional arguments, like the C function `printf'.
94    Conversions to `char *' and `std::string' are defined that return
95 the encapsulated string.  The conversion to `char *' returns a freshly
96 allocated copy of the encapsulated string; it needs to be freed using
97 `delete[]'.  The conversion to `std::string' returns a copy of the
98 encapsulated string, with automatic memory management.
100    The destructor `~autosprintf ()' destroys the encapsulated string.
102    An `operator <<' is provided that outputs the encapsulated string to
103 the given `ostream'.
105 \x1f
106 File: autosprintf.info,  Node: Using autosprintf,  Prev: Class autosprintf,  Up: Top
108 3 Using `autosprintf' in own programs
109 *************************************
111 To use the `autosprintf' class in your programs, you need to add
113      #include "autosprintf.h"
114      using gnu::autosprintf;
116 to your source code.  The include file defines the class `autosprintf',
117 in a namespace called `gnu'. The `using' statement makes it possible to
118 use the class without the (otherwise natural) `gnu::' prefix.
120    When linking your program, you need to link with `libasprintf',
121 because that's where the class is defined. In projects using GNU
122 `autoconf', this means adding `AC_LIB_LINKFLAGS([asprintf])' to
123 `configure.in' or `configure.ac', and using the @LIBASPRINTF@ Makefile
124 variable that it provides.
127 \x1f
128 Tag Table:
129 Node: Top\x7f1348
130 Node: Introduction\x7f1708
131 Node: Class autosprintf\x7f2859
132 Node: Using autosprintf\x7f3869
133 \x1f
134 End Tag Table