Qore Util Module Reference  1.1
 All Classes Namespaces Functions Variables Groups Pages
Util.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file Util.qm Qore user module for generally useful routines
3 
4 /* Util.qm Copyright 2014 Qore Technologies, sro
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // this module requires Qore 0.8.8 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 }
32 
33 /* Version History
34  * 2013-10-30 v1.1: David Nichols <david@qore.org>
35  + added the get_byte_size() and get_marketing_byte_size() functions
36 
37  * 2013-10-04 v1.0: David Nichols <david@qore.org>
38  + the initial version of the Util module
39 */
40 
67 namespace Init {
68  init();
69 
70 };
71 
73 namespace Util {
75 
88  int compare_version(string lv, string rv);
89 
90 
92 
110  string normalize_dir(string dir, string cwd = getcwd());
111 
112 
114 
129  string normalize_dir_unix(string dir, string cwd = getcwd());
130 
131 
133 
146  string normalize_dir_windows(string dir, string cwd = getcwd());
147 
148 
150 
159  bool absolute_path(string path);
160 
161 
163 
172  bool absolute_path_unix(string path);
173 
174 
176 
185  bool absolute_path_windows(string path);
186 
187 
188  // private, non-exported function: tries to split a string into a list, respects parentheses and quotes
189  any try_split(string arg);
190 
191 
192  // private, non-exported function: tries to evaluate the argument as a Qore expression/value
193  hash eval_text(string arg, bool err = False);
194 
195 
197 
204  any parse_to_qore_value(string arg);
205 
206 
208 
222  string get_random_string(softint len = 15, int level = 3);
223 
224 
226 
230  string get_exception_string(hash ex);
231 
232 
234  const StorageNames = ("Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Zetta", "Yotta", "Bronto");
235 
237 
245  string get_byte_size(softnumber n, int decimals = 2);
246 
247 
249 
257  string get_marketing_byte_size(softnumber n, int decimals = 2);
258 
259 };
string get_exception_string(hash ex)
returns a multi-line string from the exception hash argument suitable for logging or output on the co...
string normalize_dir_windows(string dir, string cwd=getcwd())
returns a normalized Windows path name (eliminates &quot;.&quot;, &quot;..&quot;, and &quot;//&quot;)
string normalize_dir(string dir, string cwd=getcwd())
returns a platform-specific normalized path name (starting from /, eliminates &quot;.&quot;, &quot;..&quot;, and &quot;//&quot;)
any parse_to_qore_value(string arg)
tries to convert a string (such as an argument given from the command-line) to a Qore value ...
string getcwd()
string get_byte_size(softnumber n, int decimals=2)
returns a string giving a user-friendly real storage size (ie based on 1KiB = 1024 bytes) in KiB...
bool absolute_path_windows(string path)
returns True if the argument is a Windows absolute path, False if not
string normalize_dir_unix(string dir, string cwd=getcwd())
returns a normalized UNIX path name (starting from /, eliminates &quot;.&quot;, &quot;..&quot;, and &quot;//&quot;) ...
const False
const StorageNames
storage names (Geop, which would normally follow Bronto, is excluded as the abbreviation would be GB/...
Definition: Util.qm.dox.h:234
int compare_version(string lv, string rv)
compares complex versions by breaking down strings into component parts
string get_random_string(softint len=15, int level=3)
function that returns a random string
hash hash(object obj)
string get_marketing_byte_size(softnumber n, int decimals=2)
returns a string giving a user-friendly &quot;marketing storage&quot; size (ie based on 1KB = 1000 bytes) in KB...
bool absolute_path(string path)
returns True if the argument is an absolute path, False if not
bool absolute_path_unix(string path)
returns True if the argument is a UNIX absolute path, False if not