Qore Util Module Reference  1.0
 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 2013 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 /* Version History
33  * 2013-10-04 v1.0: David Nichols <david@qore.org>
34  + the initial version of the Util module
35 */
36 
59 namespace Util {
62 
75  int compare_version(string lv, string rv);
76 
77 
79 
97  string normalize_dir(string dir, string cwd = getcwd());
98 
99 
101 
116  string normalize_dir_unix(string dir, string cwd = getcwd());
117 
118 
120 
133  string normalize_dir_windows(string dir, string cwd = getcwd());
134 
135 
137 
146  bool absolute_path(string path);
147 
148 
150 
159  bool absolute_path_unix(string path);
160 
161 
163 
172  bool absolute_path_windows(string path);
173 
174 
175  // private, non-exported function: tries to split a string into a list, respects parentheses and quotes
176  any try_split(string arg);
177 
178 
179  // private, non-exported function: tries to evaluate the argument as a Qore expression/value
180  hash eval_text(string arg, bool err = False);
181 
182 
184 
191  any parse_to_qore_value(string arg);
192 
193 
195 
209  string get_random_string(softint len = 15, int level = 3);
210 
211 
213 
217  string get_exception_string(hash ex);
218 
219 };
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()
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
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)
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