All Classes Namespaces Functions Variables Groups Pages
Util.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file Util.qm Qore user module for generally useful routines
/* Util.qm Copyright 2014 Qore Technologies, sro
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.8 or better
// require type definitions everywhere
// enable all warnings
}
/* Version History
* 2013-10-30 v1.1: David Nichols <david@qore.org>
+ added the get_byte_size() and get_marketing_byte_size() functions
* 2013-10-04 v1.0: David Nichols <david@qore.org>
+ the initial version of the Util module
*/
namespace Init {
init();
};
namespace Util {
int compare_version(string lv, string rv);
string normalize_dir(string dir, string cwd = getcwd());
string normalize_dir_unix(string dir, string cwd = getcwd());
string normalize_dir_windows(string dir, string cwd = getcwd());
bool absolute_path(string path);
bool absolute_path_unix(string path);
bool absolute_path_windows(string path);
// private, non-exported function: tries to split a string into a list, respects parentheses and quotes
any try_split(string arg);
// private, non-exported function: tries to evaluate the argument as a Qore expression/value
hash eval_text(string arg, bool err = False);
any parse_to_qore_value(string arg);
string get_random_string(softint len = 15, int level = 3);
string get_exception_string(hash ex);
const StorageNames = ("Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Zetta", "Yotta", "Bronto");
string get_byte_size(softnumber n, int decimals = 2);
string get_marketing_byte_size(softnumber n, int decimals = 2);
};
Util::get_exception_string
string get_exception_string(hash ex)
returns a multi-line string from the exception hash argument suitable for logging or output on the co...
Util::normalize_dir_windows
string normalize_dir_windows(string dir, string cwd=getcwd())
returns a normalized Windows path name (eliminates &quot;.&quot;, &quot;..&quot;, and &quot;//&quot;)
Util::normalize_dir
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;)
Util::parse_to_qore_value
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 ...
getcwd
string getcwd()
Util::get_byte_size
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...
Util::absolute_path_windows
bool absolute_path_windows(string path)
returns True if the argument is a Windows absolute path, False if not
Util::normalize_dir_unix
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;) ...
False
const False
Util::StorageNames
const StorageNames
storage names (Geop, which would normally follow Bronto, is excluded as the abbreviation would be GB/...
Definition: Util.qm.dox.h:234
Util::compare_version
int compare_version(string lv, string rv)
compares complex versions by breaking down strings into component parts
Util::get_random_string
string get_random_string(softint len=15, int level=3)
function that returns a random string
hash
hash hash(object obj)
Util::get_marketing_byte_size
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...
Util::absolute_path
bool absolute_path(string path)
returns True if the argument is an absolute path, False if not
Util::absolute_path_unix
bool absolute_path_unix(string path)
returns True if the argument is a UNIX absolute path, False if not