source: branches/FACT++_scripts_refactoring/doc/String.js@ 19081

Last change on this file since 19081 was 15152, checked in by tbretz, 12 years ago
Added desription for String.count
File size: 4.0 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] */ };
102
103/**
104 * Like String match, but return the number counts how often
105 * the regular expression matches.
106 *
107 * @param {String} regex
108 * The regular expression to search for, e.g., "s" (to count the s's) or
109 * "As+A" (to count how often s's are surrounded by A's)
110 *
111 * @param {Boolean} [case=false]
112 * Search is case insensitive if set to true.
113 *
114 * @returns {Interger}
115 * The number of occurances of the regular expression
116 *
117 * @example
118 * var result = "Thomas Bretz".count("[hme]"); // returns 3
119 *
120 * @author <a href="mailto:thomas.bretz@epfl.ch">Thomas Bretz</a>
121 */
122String.prototype.count = function() { /* [native code] */ };
Note: See TracBrowser for help on using the repository browser.