source: trunk/FACT++/scripts/doc/String.js@ 14873

Last change on this file since 14873 was 14675, checked in by tbretz, 12 years ago
Made sure that nobody tried to start a docu script.
File size: 3.4 KB
Line 
1throw new Error("Description for built in functions. Must not be included!");
2/**
3 * @fileOverview
4 * Documentation of the extension of the String class
5 * built into dimctrl.
6 */
7
8/**
9 * Format a string (similar to printf in C).
10 *
11 * This function replaces modifiers (very similar to printf) with
12 * a formated version of the argument. Since JavaScript does implicit
13 * format conversion already, this is actually a very powerful tool,
14 * because the type of th arguments to be formated is of no importance.
15 * Implicit conversion means that also arrays and objects can be given
16 * as arguments. A shortcut is available as $-extension of the native
17 * String class.<P>
18 *
19 * Note that this function is completely written in JavaScript. It
20 * can be found in InterpreterV8.cc.<P>
21 *
22 * The following modifiers are available (optional parts are put in
23 * brackets:<br>
24 *
25 * <li><dt><B>c:</B> <tt>%[[-][0]N]c</tt></dt>
26 * <dd>Extracts the first element from an array. In case of a String this
27 * is the first character.</dd><p>
28 *
29 * <li><dt><B>s:</B> <tt>%[[-][0]N]s</tt></dt>
30 * <dd>Converts the argument to a string using toString()</dd><p>
31 *
32 * <li><dt><B>f:</B> <tt>%[[-][0]N[.n]]f</tt></dt>
33 * <dd>Converts to a Number value with n internal decimal places</dd><p>
34 *
35 * <li><dt><B>p:</B> <tt>%[[-][0]N[.n]]p</tt></dt>
36 * <dd>Converts to a Number value with a precision of n decimal places</dd><P>
37 *
38 * <li><dt><b>e:</b> <tt>%[[-][0]N]e</tt></dt>
39 * <dd>Converts to an exponential with a precision of n decimal places</dd><p>
40 *
41 * <li><dt><b>x:</b> <tt>%[[-][0]N[#b]x</tt></dt>
42 * <dd>Converts to an integer value using the basis b for conversion
43 * (default is 16 for hexadecimal)</dd><p>
44 *
45 * <li><dt><b>d:</b> <tt>%[[-][0]N[.n][#b]]d</tt></dt>
46 * <dd>Converts from a value using the basis b for conversion (default
47 * is 10 for decimal). The integer can be rounded to the given precision n.
48 * </dd><p>
49 *
50 * The output string will have at least a length of N. If 0 is given,
51 * it is filled with 0's instead of white spaces. If prefixed by a minus
52 * the contents will be left aligned.
53 *
54 * @param {String} format
55 * The format string defining how the given argument elements are
56 * formated
57 *
58 * @param {Array} elements
59 * An array with the elements to be formated
60 *
61 * @returns {String}
62 * The formated string is returned.
63 *
64 * @see
65 * String.$
66 *
67 * @example
68 * var result;
69 * result = String.form("%5d %3d", [ 5, "2" ]);
70 * result = String.form("%5x", [ 12 ]);
71 * result = String.form("%#16d", [ "b" ]);
72 * result = String.form("%s", [ [ 1, 2, 3, ] ]);
73 * result = String.form("%s", [ { a:1, b:2, c:3, } ]);
74 * var abbrev = "%03d".$(42);
75 *
76 */
77String.form = function() { /* [native code] */ }
78
79
80/**
81 * An abbreviation for String.form.
82 *
83 * Converts all arguments provided by the user into an array
84 * which is passed to String.form. The contents of the String itself
85 * is passed as format string. This allows a very compact syntax to
86 * format any kind of object, array or number.
87 * For details see String.form.
88 *
89 * @param arg An argument to be formated.
90 * @param [. . .] An undefined number of additional optional arguments.
91 *
92 * @returns {String} see String.form
93 * @throws see String.form
94 * @see String.form
95 *
96 * @example
97 * var result = "%5d = %12s".$(5, "five");
98 *
99 * @author <a href="mailto:thomas.bretz@epfl.ch">Thomas Bretz</a>
100 */
101String.prototype.$ = function() { /* [native code] */ };
Note: See TracBrowser for help on using the repository browser.