Qore Util Module Reference  1.2
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.11 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 }
32 
74 namespace Init {
75  init();
76 
77 };
78 
80 namespace Util {
82 
95  int compare_version(string lv, string rv);
96 
97 
99 
117  string normalize_dir(string dir, string cwd = getcwd());
118 
119 
121 
136  string normalize_dir_unix(string dir, string cwd = getcwd());
137 
138 
140 
153  string normalize_dir_windows(string dir, string cwd = getcwd());
154 
155 
157 
166  bool absolute_path(string path);
167 
168 
170 
179  bool absolute_path_unix(string path);
180 
181 
183 
192  bool absolute_path_windows(string path);
193 
194 
195  // private, non-exported function: tries to split a string into a list, respects parentheses and quotes
196  any try_split(string arg);
197 
198 
199  // private, non-exported function: tries to evaluate the argument as a Qore expression/value
200  hash eval_text(string arg, bool err = False);
201 
202 
204 
211  any parse_to_qore_value(string arg);
212 
213 
215 
229  string get_random_string(softint len = 15, int level = 3);
230 
231 
233 
237  string get_exception_string(hash ex);
238 
239 
241  const StorageNames = ("Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Zetta", "Yotta", "Bronto");
242 
244 
252  string get_byte_size(softnumber n, int decimals = 2);
253 
254 
256 
264  string get_marketing_byte_size(softnumber n, int decimals = 2);
265 
266 };
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 ".", "..", and "//")
string normalize_dir(string dir, string cwd=getcwd())
returns a platform-specific normalized path name (starting from /, eliminates ".", "..", and "//")
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 ".", "..", and "//") ...
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:241
the Util namespace contains all the objects in the Util module
Definition: Util.qm.dox.h:80
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
Definition: Util.qm.dox.h:74
hash hash(object obj)
string get_marketing_byte_size(softnumber n, int decimals=2)
returns a string giving a user-friendly "marketing storage" 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