GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

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

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 GFC library. Also wraps several of GLIB utility classes.


Typedef Documentation

typedef GDateDay GFC::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 GFC::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 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 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 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

GFileError file_error_from_errno int  err_no  ) 
 

Gets a GFileError 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 GFileError corresponding to the given errno.

Unlike errno values, you can portably assume that all GFileError values will exist. Normally a GFileError 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 GFileError 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.

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.

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.

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 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.


Generated on Tue Aug 24 00:04:57 2004 for GFC-Core by doxygen 1.3.8