Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::G Namespace Reference

The C++ framework for the GObject and GLib libraries. More...

Classes

File Methods

Time Methods

Random Number Methods

Shell Methods

Time Methods

TimeVal addition operators

TimeVal subtraction operators

Miscellaneous Utility Methods

Typedefs

Enumerations

Variables


Detailed Description

The C++ framework for the GObject and GLib libraries.

Implements the object API that provides the base classes for the entire XFC library. Also wraps several of GLIB utility classes.


Typedef Documentation

typedef GDateDay Xfc::G::DateDay
 

DateDay is an integer that represents a day of the month; between 1 and 31.

G::Date::BAD_DAY represents an invalid day of the month.

typedef GDateYear Xfc::G::DateYear
 

DateYear is an integer representing a year; DATE::BAD_YEAR is the invalid value.

The year must be 1 or higher; negative (BC) years are not allowed. The year is represented with four digits.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
PRIORITY_HIGH  Use this for high priority event sources; It is not used within GLib or GTK+ (value -100).
PRIORITY_DEFAULT  Use this for default priority event sources; In GLib this priority is used when adding timeout functions with g_timeout_add(); In GDK this priority is used for events from the X server (value 0).
PRIORITY_HIGH_IDLE  Use this for high priority idle functions (value 100); GTK+ uses G_PRIORITY_HIGH_IDLE + 10 for window resizes and G_PRIORITY_HIGH_IDLE + 20 for window redraws, to ensure that any pending resizes are processed before any pending redraws, so that widgets are not redrawn twice unnecessarily; Note that you will interfere with GTK+ if you use a priority above G_PRIORITY_HIGH_IDLE + 10 (that is, GTK_PRIORITY_RESIZE).
PRIORITY_DEFAULT_IDLE  Use this for default priority idle functions; In GLib this priority is used when adding idle functions with g_idle_add() (value 200).
PRIORITY_LOW  Use this for very low priority background tasks; It is not used within GLib or GTK+ (value 300).

enum DateMonth
 

Represents a month of the year.

Enumeration values:
DATE_BAD_MONTH  Invalid value.
DATE_JANUARY  January.
DATE_FEBRUARY  February.
DATE_MARCH  March.
DATE_APRIL  April.
DATE_MAY  May.
DATE_JUNE  June.
DATE_JULY  July.
DATE_AUGUST  August.
DATE_SEPTEMBER  September.
DATE_OCTOBER  October.
DATE_NOVEMBER  November.
DATE_DECEMBER  December.

enum DateWeekday
 

Represents a day of the week.

Enumeration values:
DATE_BAD_WEEKDAY  Invalid value.
DATE_MONDAY  Monday.
DATE_TUESDAY  Tuesday.
DATE_WEDNESDAY  Wednesday.
DATE_THURSDAY  Thursday.
DATE_FRIDAY  Friday.
DATE_SATURDAY  Saturday.
DATE_SUNDAY  Sunday.

enum FileError
 

Values corresponding to errno codes returned from file operations on UNIX.

Unlike errno codes, FileError values are available on all systems. The exact meaning of each code depends on what sort of file operation you were performing; the UNIX documentation gives more details. The following error code descriptions come from the GNU C Library manual, and are under the copyright of that manual.

It's not very portable to make detailed assumptions about exactly which errors will be returned from a given operation. Some errors don't occur on some systems, etc., sometimes there are subtle differences in when a system will report a given error, etc.

Enumeration values:
FILE_ERROR_EXIST  Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
FILE_ERROR_ISDIR  File is a directory; you cannot open a directory for writing, or create or remove hard links to it.
FILE_ERROR_ACCES  Permission denied; the file permissions do not allow the attempted operation.
FILE_ERROR_NAMETOOLONG  Filename is too long.
FILE_ERROR_NOENT  No such file or directory; This is a "file doesn't exist" error for ordinary files that are referenced in contexts where they are expected to already exist.
FILE_ERROR_NOTDIR  A file that isn't a directory was specified when a directory is required.
FILE_ERROR_NXIO  No such device or address; The system tried to use the device represented by a file you specified, and it couldn't find the device; This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer.
FILE_ERROR_NODEV  This file is of a type that doesn't support mapping.
FILE_ERROR_ROFS  The directory containing the new link can't be modified because it's on a read-only file system.
FILE_ERROR_TXTBSY  Text file busy.
FILE_ERROR_FAULT  You passed in a pointer to bad memory (GLib won't reliably return this, don't pass in pointers to bad memory).
FILE_ERROR_LOOP  Too many levels of symbolic links were encountered in looking up a file name; This often indicates a cycle of symbolic links.
FILE_ERROR_NOSPC  No space left on device; write operation on a file failed because the disk is full.
FILE_ERROR_NOMEM  No memory available; The system cannot allocate more virtual memory because its capacity is full.
FILE_ERROR_MFILE  The current process has too many files open and can't open any more; Duplicate descriptors do count toward this limit.
FILE_ERROR_NFILE  There are too many distinct file openings in the entire system.
FILE_ERROR_BADF  Bad file descriptor; for example, I/O on a descriptor that has been closed or reading from a descriptor open only for writing (or vice versa).
FILE_ERROR_INVAL  Invalid argument; This is used to indicate various kinds of problems with passing the wrong argument to a library function.
FILE_ERROR_PIPE  Broken pipe; there is no process reading from the other end of a pipe (Every library function that returns this error code also generates a `SIGPIPE' signal; this signal terminates the program if not handled or blocked; Thus, your program will never actually see this code unless it has handled or blocked `SIGPIPE').
FILE_ERROR_AGAIN  Resource temporarily unavailable; the call might work if you try again later.
FILE_ERROR_INTR  Interrupted function call; an asynchronous signal occurred and prevented completion of the call (When this happens, you should try the call again).
FILE_ERROR_IO  Input/output error; usually used for physical read or write errors, that is, the disk or other physical device hardware is returning errors.
FILE_ERROR_PERM  Operation not permitted; only the owner of the file (or other resource) or processes with special privileges can perform the operation.
FILE_ERROR_NOSYS  Function not implemented; this indicates that the system is missing some functionality.
FILE_ERROR_FAILED  Does not correspond to a UNIX error code; this is the standard "failed for unspecified reason" error code present in all GError error code enumerations (Returned if no specific code applies).

enum FileTest
 

Specifies a test to perform on a file using G::file_test().

Enumeration values:
FILE_TEST_IS_REGULAR  Tests true if the file is a regular file (not a symlink or directory).
FILE_TEST_IS_SYMLINK  Tests true if the file is a symlink.
FILE_TEST_IS_DIR  Tests true if the file is a directory.
FILE_TEST_IS_EXECUTABLE  Tests true if the file is executable.
FILE_TEST_EXISTS  Tests true if the file exists. It may or may not be a regular file.

enum IOChannelError
 

enum IOChannelError The error codes returned by IOChannel operations.

Enumeration values:
IO_CHANNEL_ERROR_FBIG  File too large.
IO_CHANNEL_ERROR_INVAL  Invalid argument.
IO_CHANNEL_ERROR_IO  IO error.
IO_CHANNEL_ERROR_ISDIR  File is a directory.
IO_CHANNEL_ERROR_NOSPC  No space left on device.
IO_CHANNEL_ERROR_NXIO  No such device or address.
IO_CHANNEL_ERROR_OVERFLOW  Value too large for defined datatype.
IO_CHANNEL_ERROR_PIPE  Broken pipe.
IO_CHANNEL_ERROR_FAILED  Some other error.

enum IOCondition
 

enum IOCondition A bitwise combination representing a condition to watch for on an event source.

Enumeration values:
IO_IN  There is data to read.
IO_OUT  Data can be written (without blocking).
IO_PRI  There is urgent data to read.
IO_ERR  Error condition.
IO_HUP  Hung up (the connection has been broken, usually for pipes and sockets).
IO_NVAL  Invalid request. The file descriptor is not open.

enum IOFlags
 

enum IOFlags Specifies the properties of an IOChannel.

Some of the flags can only be read with G::IOChannel::get_flags(), but not changed with G::IOChannel::set_flags().

Enumeration values:
IO_FLAG_APPEND  Turns on append mode, corresponds to O_APPEND (see the documentation of the UNIX open() syscall).
IO_FLAG_NONBLOCK  Turns on nonblocking mode, corresponds to O_NONBLOCK/O_NDELAY (see the documentation of the UNIX open() syscall).
IO_FLAG_IS_WRITEABLE  Read only flag; Indicates that the io channel is readable.
IO_FLAG_IS_SEEKABLE  Read only flag; Indicates that the io channel is writable..
IO_FLAG_MASK  Mask flag (I dont know what this means).
IO_FLAG_GET_MASK  Same as mask flag.
IO_FLAG_SET_MASK  Turns on append mode and nonblocking mode.

enum IOStatus
 

enum IOStatus Describes the status of an IO operation.

Enumeration values:
IO_STATUS_ERROR  An error occurred.
IO_STATUS_NORMAL  Success.
IO_STATUS_EOF  End of file.
IO_STATUS_AGAIN  Resource temporarily unavailable.

enum KeyFileError
 

Specifies the error codes returned by key file parsing.

Enumeration values:
KEY_FILE_ERROR_UNKNOWN_ENCODING  The text being parsed was in an unknown encoding.
KEY_FILE_ERROR_PARSE  The document was ill-formed.
KEY_FILE_ERROR_NOT_FOUND  The file was not found.
KEY_FILE_ERROR_KEY_NOT_FOUND  A requested key was not found.
KEY_FILE_ERROR_GROUP_NOT_FOUND  A requested group was not found.
KEY_FILE_ERROR_INVALID_VALUE  A value could not be parsed.

enum KeyFileFlags
 

Specifies the flags which influence the parsing.

Enumeration values:
KEY_FILE_NONE  No flags, default behaviour.
KEY_FILE_KEEP_COMMENTS  Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise all comments will be lost when the key file is written back.
KEY_FILE_KEEP_TRANSLATIONS  Use this flag if you plan to write the (possibly modified) contents of the key file back to a file; otherwise only the translations for the current language will be written back.

enum ModuleFlags
 

enum G::ModuleFlags Flags passed to G::Module::open().

Note that these flags are not supported on all platforms.

Enumeration values:
MODULE_BIND_LAZY  Specifies that symbols are only resolved when needed; The default action is to bind all symbols when the module is loaded.
MODULE_BIND_LOCAL  Specifies that symbols in the module should not be added to the global name space.

The default action on most platforms is to place symbols in the module in the global name space, which may cause conflicts with existing symbols.

MODULE_BIND_MASK  Mask for all flags.

enum OptionError
 

Specifies the error codes returned by option parsing.

Enumeration values:
OPTION_ERROR_UNKNOWN_OPTION  An option was not known to the parser; this error will only be reported, if the parser hasn't been instructed to ignore unknown options (see set_ignore_unknown_options()).
OPTION_ERROR_BAD_VALUE  A value couldn't be parsed.

enum OptionFlags
 

Specifies the flags which modify individual options.

Enumeration values:
OPTION_FLAG_HIDDEN  The option doesn't appear in --help output.
OPTION_FLAG_IN_MAIN  The option appears in the main section of the --help output, even if it is defined in a group.
OPTION_FLAG_REVERSE  For options of the G_OPTION_ARG_NONE kind, this flag indicates that the sense of the option is reversed.

enum SeekType
 

Specifies the base position for a IOChannel::seek() operation.

Enumeration values:
IO_SEEK_CUR  The current position in the file.
IO_SEEK_SET  The start of the file.
IO_SEEK_END  The end of the file.

enum SpawnFlags
 

Specifies the flags that effect how a child process is spawned.

Enumeration values:
SPAWN_LEAVE_DESCRIPTORS_OPEN  The parent's open file descriptors will be inherited by the child; otherwise all descriptors except stdin/stdout/stderr will be closed before calling exec() in the child.
SPAWN_DO_NOT_REAP_CHILD  The child will not be automatically reaped; you must call waitpid() or handle SIGCHLD yourself, or the child will become a zombie.
SPAWN_SEARCH_PATH  argv[0] need not be an absolute path, it will be looked for in the user's PATH.
SPAWN_STDOUT_TO_DEV_NULL  The child's standard output will be discarded, instead of going to the same location as the parent's standard output.
SPAWN_STDERR_TO_DEV_NULL  The child's standard error will be discarded.
SPAWN_CHILD_INHERITS_STDIN  The child will inherit the parent's standard input (by default, the child's standard input is attached to /dev/null).
SPAWN_FILE_AND_ARGV_ZERO  The first element of argv is the file to execute, while the remaining elements are the actual argument vector to pass to the file; Normally SpawnAsync uses argv[0] as the file to execute, and passes all of argv to the child.

enum ThreadError
 

Specifies the possible errors for thread related methods.

Enumeration values:
THREAD_ERROR_AGAIN  The resource temporarily unavailable.

enum ThreadPriority
 

Specifies the priority of a thread.

It is not guaranteed, that threads with different priorities really behave accordingly. On some systems (e.g. Linux) only root can increase priorities. On other systems (e.g. Solaris) there doesn't seem to be different scheduling for different priorities. All in all try to avoid being dependent on priorities.

Enumeration values:
THREAD_PRIORITY_LOW  A priority lower than normal.
THREAD_PRIORITY_NORMAL  The default priority.
THREAD_PRIORITY_HIGH  A priority higher than normal.
THREAD_PRIORITY_URGENT  The highest priority.


Function Documentation

std::string build_filename const std::string &  s1,
const std::string &  s2,
const std::string &  s3,
const std::string &  s4
 

Creates a filename from 4 elements using the correct separator for filenames (see build_filename(const std::string&, const std::string&).

Parameters:
s1 The first element in the filename.
s2 The second element in the filename.
s3 The third element in the filename.
s4 The fourth element in the filename.
Returns:
The resulting filename.

std::string build_filename const std::string &  s1,
const std::string &  s2,
const std::string &  s3
 

Creates a filename from 3 elements using the correct separator for filenames (see build_filename(const std::string&, const std::string&).

Parameters:
s1 The first element in the filename.
s2 The second element in the filename.
s3 The third element in the filename.
Returns:
The resulting filename.

std::string build_filename const std::string &  s1,
const std::string &  s2
 

Creates a filename from 2 elements using the correct separator for filenames.

Parameters:
s1 The first element in the filename.
s2 The second element in the filename.
Returns:
The resulting filename.
On Unix, this function behaves identically to G::build_path() with G_DIR_SEPARATOR_S set as the separator. On Windows, it takes into account that either the backslash "\" or slash "/" can be used as separator in filenames, but otherwise behaves as on Unix. When file pathname separators need to be inserted, the one that last previously occurred in the parameters (reading from left to right) is used. No attempt is made to force the resulting filename to be an absolute path. If the first element is a relative path, the result will be a relative path.

std::string build_path const std::string &  separator,
const std::string &  s1,
const std::string &  s2,
const std::string &  s3,
const std::string &  s4
 

Creates a path from 4 elements using separator as the separator between elements (see build_path(const std::string&, const std::string&, const std::string&).

Parameters:
separator A string used to separator the elements of the path.
s1 The first element in the path.
s2 The second element in the path.
s3 The third element in the path.
s4 The fourth element in the path.
Returns:
The resulting path.

std::string build_path const std::string &  separator,
const std::string &  s1,
const std::string &  s2,
const std::string &  s3
 

Creates a path from 3 elements using separator as the separator between elements (see build_path(const std::string&, const std::string&, const std::string&).

Parameters:
separator A string used to separator the elements of the path.
s1 The first element in the path.
s2 The second element in the path.
s3 The third element in the path.
Returns:
The resulting path.

std::string build_path const std::string &  separator,
const std::string &  s1,
const std::string &  s2
 

Creates a path from 2 elements using separator as the separator between elements.

Parameters:
separator A string used to separator the elements of the path.
s1 The first element in the path.
s2 The second element in the path.
Returns:
The resulting path.
At the boundary between two elements, any trailing occurrences of separator in the first element, or leading occurrences of separator in the second element are removed and exactly one copy of the separator is inserted. Empty elements are ignored.

The number of leading copies of the separator on the result is the same as the number of leading copies of the separator on the first non-empty element. The number of trailing copies of the separator on the result is the same as the number of trailing copies of the separator on the last non-empty element. (Determination of the number of trailing copies is done without stripping leading copies, so if the separator is ABA, ABABA has 1 trailing copy.)

If there is only a single non-empty element, and there are no characters in that element not part of the leading or trailing separators, then the result is exactly the original value of that element. Other than for determination of the number of leading and trailing copies of the separator, elements consisting only of copies of the separator are ignored.

FileError file_error_from_errno int  err_no  ) 
 

Gets a FileError constant based on the passed-in errno, for example, if you pass in EEXIST this function returns G_FILE_ERROR_EXIST.

Parameters:
err_no An "errno" value
Returns:
A FileError corresponding to the given errno.
Unlike errno values, you can portably assume that all FileError values will exist. Normally a FileError value goes into a G::Error returned from a method that manipulates files. So you would use G::file_error_from_errno() when constructing a G::Error.

bool file_get_contents const std::string &  filename,
std::string &  contents,
G::Error *  error
 

Reads an entire file into allocated memory, with good error checking.

Parameters:
filename A file to read the contents from.
contents The location to store the file contents.
error The return location for a G::Error.
Returns:
true on success, false if error is set.
If error is set, false is returned, and contents is set to an empty string. If true is returned, error will not be set, and contents will be set to the file contents. The error domain is G_FILE_ERROR. Possible error codes are those in the FileError enumeration.

bool file_test const std::string &  filename,
FileTestField  test
 

Determines whether any of the tests in the bitfield test are true.

Parameters:
filename A filename to test.
test A bitfield of G::FileTest flags.
Returns:
true if a test was true.
For example, (G::FILE_TEST_EXISTS | G::FILE_TEST_IS_DIR) will return true if the file exists; the check whether it's a directory doesn't matter since the existence test is true. With the current set of available tests, there's no point passing in more than one test at a time.

Apart from G::FILE_TEST_IS_SYMLINK all tests follow symbolic links, so for a symbolic link to a regular file file_test() will return true for both G::FILE_TEST_IS_SYMLINK and G::FILE_TEST_IS_REGULAR. Note, that for a dangling symbolic link file_test() will return true for G::FILE_TEST_IS_SYMLINK and false for all other flags.

You should never use file_test() to test whether it is safe to perform an operaton, because there is always the possibility of the condition changing before you actually perform the operation. For example, you might think you could use G::FILE_TEST_IS_SYMLINK to know whether it is is safe to write to a file without being tricked into writing into a different location. It doesn't work!

Example: DON'T DO THIS.

     if (!file_test(filename, FILE_TEST_IS_SYMLINK))
     {
        TempFile file(filename);
        if (file.is_open())
        // write to file
     }

Another thing to note is that G::FILE_TEST_EXISTS and G::FILE_TEST_IS_EXECUTABLE are implemented using the access() system call. This usually doesn't matter, but if your program is setuid or setgid it means that these tests will give you the answer for the real user ID and group ID , rather than the effective user ID and group ID.

std::string find_program_in_path const std::string &  program  ) 
 

Locates the first executable named program in the user's path, in the same way that execvp() locates it.

Parameters:
program A program name.
Returns:
A string with the absolute path name, or an empty string if the program is not found in the path.
If program is already an absolute path, returns a copy of program if program exists and is executable, and an empty string otherwise. On Windows, if program does not have a file type suffix, tries to append the suffixes in the PATHEXT environment variable (if that doesn't exists, the suffixes .com, .exe, and .bat) in turn, and then look for the resulting file name in the same way as CreateProcess() would. This means first in the directory where the program was loaded from, then in the current directory, then in the Windows 32-bit system directory, then in the Windows directory, and finally in the directories in the PATH environment variable. If the program is found, the return value contains the full name including the type suffix.

String get_application_name  ) 
 

Gets a human-readable name for the application, as set by set_application_name().

Returns:
A human-readable application name (may return a null string).
This name should be localized if possible, and is intended for display to the user. Contrast with get_prgname(), which gets a non-localized name. If set_application_name() has not been called, returns the result of get_prgname() (which may be null if set_prgname() has also not been called).

std::string get_current_dir  ) 
 

Gets the current directory.

Returns:
The current directory.
The encoding of the returned string is system defined. On Windows, it is always UTF-8.

TimeVal get_current_time  ) 
 

Equivalent to the UNIX gettimeofday() function, but portable.

Returns:
A TimeVal object that stores the current time.

void get_current_time TimeVal &  timeval  ) 
 

Equivalent to the UNIX gettimeofday() function, but portable.

Parameters:
timeval A TimeVal object in which to store the current time.

std::string get_home_dir  ) 
 

Gets the current user's home directory.

Returns:
The current user's home directory.
Note that in contrast to traditional Unix tools, this function prefers passwd entries over the HOME environment variable.

std::string get_prgname  ) 
 

Gets the name of the program.

Returns:
The name of the program.
This name should NOT be localized, contrast with get_application_name(). If you are using libXFCui the program name is set in Main::init(). The program name is found by taking the last component of argv[0].

std::string get_real_name  ) 
 

Gets the real name of the user.

Returns:
The user's real name.
This usually comes from the user's entry in the passwd file. The encoding of the returned string is system defined. (On Windows, it is, however, always UTF-8.) If the real user name cannot be determined, the string "Unknown" is returned.

std::vector<std::string> get_system_config_dirs  ) 
 

Gets an ordered list of base directories in which to access system-wide configuration information.

Returns:
A vector of std::string holding the list of base directories.
On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification

std::vector<std::string> get_system_data_dirs  ) 
 

Gets an ordered list of base directories in which to access system-wide application data.

Returns:
A vector of std::string holding the ordered list of base directories.
On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.

std::string get_tmp_dir  ) 
 

Gets the directory to use for temporary files.

Returns:
The directory to use for temporary files.
This is found from inspecting the environment variables TMPDIR, TMP, and TEMP in that order. If none of those are defined "/tmp" is returned on UNIX and "C:\" on Windows. The encoding of the returned string is system defined. On Windows, it is always UTF-8. The return value is never null.

std::string get_user_cache_dir  ) 
 

Gets the base directory in which to store non-essential, cached data specific to particular user.

Returns:
The base directory string.
On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.

std::string get_user_config_dir  ) 
 

Gets the base directory in which to store user-specific application configuration information such as user preferences and settings.

Returns:
The base directory string.
On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.

std::string get_user_data_dir  ) 
 

Gets the base directory in which to access application data such as icons that is customized for a particular user.

Returns:
The base directory string.
On Unix platforms this is determined using the mechanisms described in the XDG Base Directory Specification.

std::string get_user_name  ) 
 

Gets the user name of the current user.

Returns:
The user name of the current user.
The encoding of the returned string is system defined. On Unix, it might be the preferred file name encoding, or something else, and there is no guarantee that it is even consistent on a machine. On Windows, it is always UTF-8.

std::string getenv const std::string &  variable  ) 
 

Gets the value of an environment variable.

Parameters:
variable The environment variable to get.
Returns:
The value of the environment variable, or an empty string if variable is not found.
The returned string may be overwritten by the next call to getenv(), setenv() or unsetenv().

std::string path_get_basename const std::string &  file_name  ) 
 

Gets the last component of the filename.

Parameters:
file_name The name of the file.
Returns:
A string containing the last component of the filename.
If file_name ends with a directory separator it gets the component before the last slash. If file_name consists only of directory separators (and on Windows, possibly a drive letter), a single separator is returned. If file_name is empty, "." is returned.

std::string path_get_dirname const std::string &  file_name  ) 
 

Gets the directory components of a file name.

Parameters:
file_name The name of the file.
Returns:
The directory components of the file.
If the file name has no directory components "." is returned.

bool path_is_absolute const std::string &  file_name  ) 
 

Determines whether the given file_name is an absolute file name.

Parameters:
file_name A file name.
Returns:
true if file_name is an absolute path.
A file name is absolute if it contains a full path from the root directory such as "/usr/local" on UNIX or "C:\windows" on Windows systems.

std::string path_skip_root const std::string &  file_name  ) 
 

Gets a pointer into file_name after the root component, that is, after the "/" in UNIX or "C:\' under Windows.

Parameters:
file_name A file name.
Returns:
A pointer into file_name after the root component.
If file_name is not an absolute path it returns an empty string.

bool random_boolean  ) 
 

Gets a random boolean value (this corresponds to a unbiased coin toss).

Returns:
A random bool value.

double random_double  ) 
 

Gets a random double equally distributed over the range [0..1).

Returns:
A random number.

double random_double_range double  begin,
double  end
 

Gets a random double equally distributed over the range [begin..end).

Parameters:
begin The lower closed bound of the interval.
end The upper open bound of the interval.
Returns:
A random number.

unsigned int random_int  ) 
 

Gets a random unsigned integer equally distributed over the range [0..2^32-1].

Returns:
A random number.

int random_int_range int  begin,
int  end
 

Gets a random integer equally distributed over the range [begin..end-1].

Parameters:
begin The lower closed bound of the interval.
end The upper open bound of the interval.
Returns:
A random number.

void random_set_seed unsigned int  seed  ) 
 

Sets the seed for the global random number generator, which is used by the G::random_* methods, to seed.

Parameters:
seed A value to reinitialize the global random number generator.

void set_application_name const String &  application_name  ) 
 

Sets a human-readable name for the application.

Parameters:
application_name The localized name of the application.
This name should be localized if possible, and is intended for display to the user. Contrast with set_prgname(), which sets a non-localized name. set_prgname() will be called automatically by Main::init(), but set_application_name() will not. Note that for thread safety reasons, this function can only be called once. The application name will be used in contexts such as error messages, or when displaying an application's name in the task list.

void set_prgname const std::string &  prgname  ) 
 

Sets the name of the program.

Parameters:
prgname The name of the program.
This name should NOT be localized, contrast with set_application_name(). Note that for thread-safety reasons this function can only be called once.

bool setenv const std::string &  variable,
const std::string &  value,
bool  overwrite
 

Sets the value of an environment variable.

Parameters:
variable The environment variable to set, must not contain "=".
value The value to set for the variable.
overwrite Whether to change the variable if it already exists.
Returns:
false if the environment variable couldn't be set.
Note that on some systems, the memory used for the variable and its value can't be reclaimed.

bool shell_parse_argv const String &  command_line,
std::vector< String > &  args,
G::Error *  error = 0
 

Parses a command line into an argument vector, in much the same way the shell would, but without many of the expansions the shell would perform (variable expansion, globs, operators, filename expansion, and the like are not supported).

Parameters:
command_line A command line to parse.
args A reference to a vector of String to hold the argument strings.
error The return location for a G::Error, or null.
Returns:
true on success, false if error was set.
The results are defined to be the same as those you would get from a UNIX98 /bin/sh, as long as the input contains none of the unsupported shell expansions. If the input does contain such expansions, they are passed through literally. Possible errors are those from the G_SHELL_ERROR domain.

String shell_quote const String &  unquoted_string  ) 
 

Quotes a string so that the shell (/bin/sh) will interpret the quoted string to mean unquoted_string.

Parameters:
unquoted_string A literal string
Returns:
The quoted string.
If you pass a filename to the shell, for example, you should first quote it with this function. The quoting style used is undefined (single or double quotes may be used).

String shell_unquote const String &  quoted_string,
G::Error *  error = 0
 

Unquotes a string as the shell (/bin/sh) would.

Parameters:
quoted_string A shell-quoted string.
error The return location for a G::Error, or null.
Returns:
An unquoted string.
Only handles quotes; if a string contains file globs, arithmetic operators, variables, backticks, redirections, or other special-to-the-shell features, the result will be different from the result a real shell would produce (the variables, backticks, etc. will be passed through literally instead of being expanded). This method is guaranteed to succeed if applied to the result of shell_quote(). If it fails, it returns a null String and sets the error. The quoted_string need not actually contain quoted or escaped text; shell_unquote() simply goes through the string and unquotes/unescapes anything that the shell would. Both single and double quotes are handled, as are escapes including escaped newlines. Possible errors are in the G_SHELL_ERROR domain.

Shell quoting rules are a bit strange. Single quotes preserve the literal string exactly. Escape sequences are not allowed; not even \' - if you want a ' in the quoted text, you have to do something like 'foo'\''bar'. Double quotes allow $, `, ", \, and newline to be escaped with backslash. Otherwise double quotes preserve things literally.

void unsetenv const std::string &  variable  ) 
 

Removes an environment variable from the environment.

Parameters:
variable The environment variable to remove, must not contain "=".
Note that on some systems, the memory used for the variable and its value can't be reclaimed. Furthermore, this function can't be guaranteed to operate in a threadsafe way.

void usleep unsigned long  microseconds  ) 
 

Pauses execution of the current thread for the given number of microseconds.

Parameters:
microseconds The number of microseconds to pause.
There are 1 million microseconds per second (represented by the G_USEC_PER_SEC macro). This method may have limited precision, depending on hardware and operating system; don't rely on the exact length of the sleep.
Xfce Foundation Classes


Copyright © 2004-2005 The XFC Development Team XFC 4.3