The Planetary Image Research Laboratory. More...
Classes | |
class | Data_Binder |
A Data_Binder binds an object to data of some amount. More... | |
class | Binary_IO |
The Binary_IO class provides input and output of binary data values. More... | |
struct | Binary_Input |
Binary_Input is a subclass of Binary_IO that contains an istream reference. More... | |
struct | Binary_Output |
Binary_Output is a subclass of Binary_IO that contains an ostream reference. More... | |
class | Cache |
A Cache is a dynamic input storage area. More... | |
class | Data_Block |
A Data_Block manages access to a block of binary data bytes. More... | |
struct | Point_2D |
A Point_2D holds 2-dimensional position information. More... | |
struct | Size_2D |
A Size_2D holds 2-dimensional size information. More... | |
struct | Rectangle |
A Rectangle is a position with a size. More... | |
struct | Cube |
A Cube is a Rectangle with depth. More... | |
class | Reference_Counted_Pointer |
A Reference_Counted_Pointer acts like a normal pointer with the addition of reference counting. More... | |
Typedefs | |
typedef COORDINATE_TYPE | Coordinate_Type |
The integer data type of a coordinate value. | |
typedef DIMENSIONS_TYPE | Dimensions_Type |
The integer data type of a dimension value. | |
Functions | |
std::istream & | operator>> (std::istream &stream, const Binary_IO::Binder &binder) |
Implements the stream input Binary_IO manipulator operator. | |
std::ostream & | operator<< (std::ostream &stream, const Binary_IO::Binder &binder) |
Implements the stream output Binary_IO manipulator operator. | |
std::ostream & | operator<< (std::ostream &stream, const Data_Block &data_block) |
Prints a description of the Data_Block to a stream. | |
std::istream & | operator>>= (std::istream &stream, Data_Block &data_block) |
Input data bytes from a stream into the data block. | |
std::ostream & | operator<<= (std::ostream &stream, const Data_Block &data_block) |
Output data bytes from the data block into a stream. | |
std::ostream & | operator<< (std::ostream &stream, const Point_2D &point) |
Print a Point_2D description to an output stream. | |
std::ostream & | operator<< (std::ostream &stream, const Size_2D &size) |
Print a Size_2D description to an output stream. | |
std::ostream & | operator<< (std::ostream &stream, const Rectangle &rectangle) |
Print a Rectangle description to an output stream. | |
std::ostream & | operator<< (std::ostream &stream, const Cube &cube) |
Print a Cube description to an output stream. | |
Coordinate_Type | Round (double number) |
Rounds a floating point number to the nearest integer value. | |
Point_2D | operator+ (const Point_2D &point_1, const Point_2D &point_2) |
Add two points. | |
Point_2D | operator- (const Point_2D &point_1, const Point_2D &point_2) |
Subtract one point from another. | |
Point_2D | operator- (const Point_2D &point) |
Get the negation of a point. | |
Point_2D | operator* (const Point_2D &point, double factor) |
Multiply a point by a factor. | |
Point_2D | operator* (double factor, const Point_2D &point) |
Multiply a point by a factor. | |
Point_2D | operator/ (const Point_2D &point, double factor) |
Divide a point by a factor. | |
Size_2D | operator+ (const Size_2D &size_1, const Size_2D &size_2) |
Add two sizes. | |
Size_2D | operator- (const Size_2D &size_1, const Size_2D &size_2) |
Subtract one size from another. | |
Size_2D | operator* (const Size_2D &size, double factor) |
Multiply a size by a factor. | |
Size_2D | operator* (double factor, const Size_2D &size) |
Multiply a size by a factor. | |
Size_2D | operator/ (const Size_2D &size, double factor) |
Divide a size by a factor. | |
Rectangle | operator+ (const Rectangle &rectangle, const Point_2D &point) |
Add a Point_2D offset to a Rectangle. | |
Rectangle | operator+ (const Point_2D &point, const Rectangle &rectangle) |
Add a Point_2D offset to a Rectangle. | |
Rectangle | operator+ (const Rectangle &rectangle_1, const Rectangle &rectangle_2) |
Add two Rectangles. | |
Rectangle | operator- (const Rectangle &rectangle, const Point_2D &point) |
Subtract a Point_2D offset from a Rectangle. | |
Rectangle | operator- (const Rectangle &rectangle_1, const Rectangle &rectangle_2) |
Subtract two Rectangles. | |
Rectangle | operator- (const Rectangle &rectangle) |
Get the negation of a Rectangle. | |
Rectangle | operator+ (const Rectangle &rectangle, const Size_2D &size) |
Add a size amount to a Rectangle. | |
Rectangle | operator+ (const Size_2D &size, const Rectangle &rectangle) |
Add a size amount to a Rectangle. | |
Rectangle | operator- (const Rectangle &rectangle, const Size_2D &size) |
Subtract a size amount from a Rectangle. | |
Rectangle | operator* (const Rectangle &rectangle, double factor) |
Multiply a Rectangle by a factor. | |
Rectangle | operator* (double factor, const Rectangle &rectangle) |
Multiply a Rectangle by a factor. | |
Rectangle | operator/ (const Rectangle &rectangle, double factor) |
Divide a Rectangle by a factor. | |
Rectangle | operator& (const Rectangle &rectangle_1, const Rectangle &rectangle_2) |
Get the intersection of two Rectangles. | |
Rectangle & | operator| (const Rectangle &rectangle_1, const Rectangle &rectangle_2) |
Get the union of two Rectangles. | |
Cube | operator+ (const Cube &cube, int amount) |
Add an amount to a Cube Depth. | |
Cube | operator- (const Cube &cube, int amount) |
Subtract an amount from a Cube Depth. | |
Cube | operator+ (const Cube &cube_1, const Cube &cube_2) |
Add two Cubes. | |
Cube | operator- (const Cube &cube_1, const Cube &cube_2) |
Subtract two Cubes. | |
Cube | operator* (const Cube &cube, double factor) |
Multiply a Cube by a factor. | |
Cube | operator* (double factor, const Cube &cube) |
Multiply a Cube by a factor. | |
Cube | operator/ (const Cube &cube, double factor) |
Divide a Cube by a factor. | |
Cube | operator& (const Cube &cube_1, const Cube &cube_2) |
Get the intersection of two Cubes. | |
Cube & | operator| (const Cube &cube_1, const Cube &cube_2) |
Get the union of two Cubes. | |
bool | host_is_high_endian () |
Tests if the host system is high-endian. | |
void | reorder_bytes (unsigned char *data, const unsigned long amount) |
Reorders data bytes. | |
void | reorder_bytes (unsigned char *data, const unsigned long groups, const unsigned int size) |
Reorders data bytes in groups. | |
void | swap_bytes (unsigned char *data, const unsigned int groups, const unsigned int size) |
Swap groups of data bytes. | |
bool | high_endian_host () |
Tests if the host system is high-endian. | |
bool | big_endian_host () |
Tests if the host system is big-endian. | |
bool | low_endian_host () |
Tests if the host system is low-endian. | |
bool | little_endian_host () |
Tests if the host system is little-endian. | |
template<typename T > | |
T & | MSB_native (T &value) |
A MSB (high-endian) data value is coerced to/from native byte order. | |
template<typename T > | |
T & | LSB_native (T &value) |
A LSB (low-endian) data value is coerced to/from native byte order. | |
bool | file_exists (const std::string &pathname) |
Test if a file exists at a pathname. | |
bool | file_is_normal (const std::string &pathname) |
Test if a file at a pathname is a normal file. | |
bool | file_is_directory (const std::string &pathname) |
Test if a file at a pathname is a directory. | |
bool | file_is_link (const std::string &pathname) |
Test if a file at a pathname is a link file. | |
off_t | file_size (const std::string &pathname) |
Get the size of a file. | |
bool | file_is_absolute (const std::string &pathname) |
Test if a pathname is an absolute pathname. | |
std::string & | clean_pathname (std::string &pathname) |
Clean a pathname of redundant segments. | |
std::string | CWD () |
Get the current working directory of the process. | |
std::string | file_pathname (const std::string &filename) |
Get the full pathname for a filename. | |
std::string | file_pathname (const std::string &directory, const std::string &filename) |
Get the full pathname for a filename. | |
std::string | file_directory (const std::string &pathname) |
Get the leading directory portion of a pathname. | |
std::string | file_directory_pathname (const std::string &pathname) |
Get the leading directory pathname portion of a pathname. | |
std::string | file_name (const std::string &pathname) |
Get the final name portion of a pathname. | |
std::string | file_basename (const std::string &pathname) |
Get the basename of a file's pathname. | |
std::string | file_extension (const std::string &pathname) |
Get a file's extension. | |
bool | file_is_readable (const std::string &pathname) |
Test if a file at a pathname is readable. | |
bool | file_is_writeable (const std::string &pathname) |
Test if a file at a pathname is writeable. | |
std::string | home_directory_pathname () |
Get the user's home directory pathname. | |
std::string | username () |
Get the effective username. | |
unsigned int | UID () |
Get the effective user ID. | |
unsigned int | GID () |
Get the effective group ID. | |
std::string | hostname () |
Get the name of the host system. | |
Variables | |
const char * | Files_ID = "PIRL::Files ($Revision: 2.4 $ $Date: 2010/11/21 20:33:26 $)" |
Module identification name with source code version and date. | |
const char | FILE_PATHNAME_DELIMITER = PATHNAME_DELIMITER |
Host filesystem pathname delimiter ('/'). | |
const char | FILE_EXTENSION_DELIMITER = EXTENSION_DELIMITER |
Filename extension delimiter ('.'). |
The Planetary Image Research Laboratory.
The Planetary Image Research Laboratory (http://PIRL.LPL.Arizona.edu/) is located at the University of Arizona in the Department of Planetary Sciences and Lunar and Planetary Laboratory (http://www.lpl.arizona.edu/).
typedef COORDINATE_TYPE PIRL::Coordinate_Type |
The integer data type of a coordinate value.
typedef DIMENSIONS_TYPE PIRL::Dimensions_Type |
The integer data type of a dimension value.
std::istream& PIRL::operator>> | ( | std::istream & | stream, |
const Binary_IO::Binder & | binder | ||
) | [inline] |
Implements the stream input Binary_IO manipulator operator.
References PIRL::Data_Binder< Bindor_object >::Amount, PIRL::Data_Binder< Bindor_object >::Bindor, and PIRL::Data_Binder< Bindor_object >::Data.
std::ostream& PIRL::operator<< | ( | std::ostream & | stream, |
const Binary_IO::Binder & | binder | ||
) | [inline] |
Implements the stream output Binary_IO manipulator operator.
References PIRL::Data_Binder< Bindor_object >::Amount, PIRL::Data_Binder< Bindor_object >::Bindor, and PIRL::Data_Binder< Bindor_object >::Data.
std::ostream & PIRL::operator<< | ( | std::ostream & | stream, |
const Data_Block & | data_block | ||
) |
Prints a description of the Data_Block to a stream.
stream | The ostream to which to print the description. |
data_block | The Data_Block to describe. |
References PIRL::Data_Block::print().
std::istream & PIRL::operator>>= | ( | std::istream & | stream, |
Data_Block & | data_block | ||
) |
Input data bytes from a stream into the data block.
stream | The istream from which to read the data. |
data_block | The Data_Block to receive the data. |
References PIRL::Data_Block::input().
std::ostream & PIRL::operator<<= | ( | std::ostream & | stream, |
const Data_Block & | data_block | ||
) |
Output data bytes from the data block into a stream.
stream | The ostream to which to write the data. |
data_block | The Data_Block to write. |
References PIRL::Data_Block::output().
std::ostream & PIRL::operator<< | ( | std::ostream & | stream, |
const Point_2D & | point | ||
) |
Print a Point_2D description to an output stream.
stream | The ostream where the Point_2D will be printed. |
point | The Print_2D to be printed. |
References PIRL::Point_2D::X, and PIRL::Point_2D::Y.
std::ostream & PIRL::operator<< | ( | std::ostream & | stream, |
const Size_2D & | size | ||
) |
Print a Size_2D description to an output stream.
References PIRL::Size_2D::Height, and PIRL::Size_2D::Width.
std::ostream & PIRL::operator<< | ( | std::ostream & | stream, |
const Rectangle & | rectangle | ||
) |
std::ostream & PIRL::operator<< | ( | std::ostream & | stream, |
const Cube & | cube | ||
) |
Print a Cube description to an output stream.
References PIRL::Cube::Depth.
Coordinate_Type PIRL::Round | ( | double | number ) | [inline] |
Rounds a floating point number to the nearest integer value.
The nearest integer value is found by adding 0.5 to the floating point number and truncating the result to the Coordinate_Type integer value. For negative numbers 0.5 is subtracted. Thus a floating point number exactly halfway beteen two integer values is rounded to the absolute larger integer with the sign preserved.
number | The floating point (double) number to be rounded. |
Referenced by PIRL::Cube::operator*=(), PIRL::Point_2D::operator*=(), PIRL::Size_2D::operator*=(), PIRL::Cube::operator/=(), PIRL::Size_2D::operator/=(), and PIRL::Point_2D::operator/=().
Point_2D PIRL::operator+ | ( | const Point_2D & | point_1, |
const Point_2D & | point_2 | ||
) | [inline] |
Point_2D PIRL::operator- | ( | const Point_2D & | point_1, |
const Point_2D & | point_2 | ||
) | [inline] |
Point_2D PIRL::operator- | ( | const Point_2D & | point ) | [inline] |
Get the negation of a point.
point | A Point_2D. |
References PIRL::Point_2D::X, and PIRL::Point_2D::Y.
Point_2D PIRL::operator* | ( | const Point_2D & | point, |
double | factor | ||
) | [inline] |
Point_2D PIRL::operator* | ( | double | factor, |
const Point_2D & | point | ||
) | [inline] |
Point_2D PIRL::operator/ | ( | const Point_2D & | point, |
double | factor | ||
) | [inline] |
Size_2D PIRL::operator+ | ( | const Size_2D & | size_1, |
const Size_2D & | size_2 | ||
) | [inline] |
Size_2D PIRL::operator- | ( | const Size_2D & | size_1, |
const Size_2D & | size_2 | ||
) | [inline] |
Subtract one size from another.
N.B.: If the size Dimensions_Type values are an unsigned type (as they are by default) and a size amount to be subtracted is greater than the corresponding dimension value, the result will be zero.
Size_2D PIRL::operator* | ( | const Size_2D & | size, |
double | factor | ||
) | [inline] |
Multiply a size by a factor.
size | A Size_2D. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Size_2D PIRL::operator* | ( | double | factor, |
const Size_2D & | size | ||
) | [inline] |
Multiply a size by a factor.
factor | A floating point (double) number. |
size | A Size_2D. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Size_2D PIRL::operator/ | ( | const Size_2D & | size, |
double | factor | ||
) | [inline] |
Divide a size by a factor.
size | A Size_2D. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Rectangle PIRL::operator+ | ( | const Rectangle & | rectangle, |
const Point_2D & | point | ||
) | [inline] |
Rectangle PIRL::operator+ | ( | const Point_2D & | point, |
const Rectangle & | rectangle | ||
) | [inline] |
Rectangle PIRL::operator+ | ( | const Rectangle & | rectangle_1, |
const Rectangle & | rectangle_2 | ||
) | [inline] |
Rectangle PIRL::operator- | ( | const Rectangle & | rectangle, |
const Point_2D & | point | ||
) | [inline] |
Rectangle PIRL::operator- | ( | const Rectangle & | rectangle_1, |
const Rectangle & | rectangle_2 | ||
) | [inline] |
Rectangle PIRL::operator- | ( | const Rectangle & | rectangle ) | [inline] |
Get the negation of a Rectangle.
rectangle | A Rectangle. |
References PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.
Rectangle PIRL::operator+ | ( | const Rectangle & | rectangle, |
const Size_2D & | size | ||
) | [inline] |
Rectangle PIRL::operator+ | ( | const Size_2D & | size, |
const Rectangle & | rectangle | ||
) | [inline] |
Rectangle PIRL::operator- | ( | const Rectangle & | rectangle, |
const Size_2D & | size | ||
) | [inline] |
Subtract a size amount from a Rectangle.
N.B.: If the size Dimensions_Type values are an unsigned type (as they are by default) and a size amount to be subtracted is greater than the corresponding dimension value, the result will be zero.
Rectangle PIRL::operator* | ( | const Rectangle & | rectangle, |
double | factor | ||
) | [inline] |
Multiply a Rectangle by a factor.
rectangle | A Rectangle. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Rectangle PIRL::operator* | ( | double | factor, |
const Rectangle & | rectangle | ||
) | [inline] |
Multiply a Rectangle by a factor.
factor | A floating point (double) number. |
rectangle | A Rectangle. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Rectangle PIRL::operator/ | ( | const Rectangle & | rectangle, |
double | factor | ||
) | [inline] |
Divide a Rectangle by a factor.
The new size dimensions will be rounded to the nearest Dimensions_Type values.
N.B.: Divide by zero is handled as a special case. If the coordinate value was zero it will remain zero. If the Dimensions_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Dimensions_Type is signed the type's max value is used, or the min value if the coordinate value is negative; for an unsigned value the max value is used.
rectangle | A Rectangle. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Rectangle PIRL::operator& | ( | const Rectangle & | rectangle_1, |
const Rectangle & | rectangle_2 | ||
) | [inline] |
Get the intersection of two Rectangles.
Rectangle& PIRL::operator| | ( | const Rectangle & | rectangle_1, |
const Rectangle & | rectangle_2 | ||
) | [inline] |
Cube PIRL::operator+ | ( | const Cube & | cube, |
int | amount | ||
) | [inline] |
Add an amount to a Cube Depth.
cube | A Cube. |
amount | An integer amount to add to the Depth. |
Cube PIRL::operator- | ( | const Cube & | cube, |
int | amount | ||
) | [inline] |
Subtract an amount from a Cube Depth.
cube | A Cube. |
amount | An integer amount to substract from the Depth of the other cube. |
Cube PIRL::operator+ | ( | const Cube & | cube_1, |
const Cube & | cube_2 | ||
) | [inline] |
Add two Cubes.
Cube PIRL::operator- | ( | const Cube & | cube_1, |
const Cube & | cube_2 | ||
) | [inline] |
Subtract two Cubes.
Cube PIRL::operator* | ( | const Cube & | cube, |
double | factor | ||
) | [inline] |
Multiply a Cube by a factor.
cube | A Cube. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Cube PIRL::operator* | ( | double | factor, |
const Cube & | cube | ||
) | [inline] |
Multiply a Cube by a factor.
factor | A floating point (double) number. |
cube | A Cube. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Cube PIRL::operator/ | ( | const Cube & | cube, |
double | factor | ||
) | [inline] |
Divide a Cube by a factor.
The new size dimensions will be rounded to the nearest Dimensions_Type values.
N.B.: Divide by zero is handled as a special case. If the coordinate value was zero it will remain zero. If the Dimensions_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Dimensions_Type is signed the type's max value is used, or the min value if the coordinate value is negative; for an unsigned value the max value is used.
cube | A Cube. |
factor | A floating point (double) number. |
invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Cube PIRL::operator& | ( | const Cube & | cube_1, |
const Cube & | cube_2 | ||
) | [inline] |
Get the intersection of two Cubes.
The intersection the Depths of two Cubes is the minimum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.
Cube& PIRL::operator| | ( | const Cube & | cube_1, |
const Cube & | cube_2 | ||
) | [inline] |
Get the union of two Cubes.
The union of the Depths of two Cubes is the maximum Depth; i.e. the two Cubes are assumed to be aligned at the zero X-Y plane.
bool PIRL::host_is_high_endian | ( | ) |
Tests if the host system is high-endian.
A system is high-endian if native multi-byte binary data is ordered most significant byte (MSB) first. In this case the MSB will be at the lowest address of each datum's bytes, with each subsequent byte at a higher address until the least significant byte (LSB) is at the highest address.
Referenced by big_endian_host(), PIRL::Data_Block::data_order(), PIRL::Data_Block::get_backwards(), PIRL::Data_Block::get_forwards(), high_endian_host(), little_endian_host(), low_endian_host(), LSB_native(), MSB_native(), PIRL::Data_Block::native_order(), PIRL::Data_Block::put_backwards(), and PIRL::Data_Block::put_forwards().
void PIRL::reorder_bytes | ( | unsigned char * | data, |
const unsigned long | amount | ||
) |
Reorders data bytes.
The bytes are mirrored, in place. The first byte is swapped with the last byte, the second byte is swapped with the next-to-last byte, etc. until all byte pairs have been swapped.
data | A pointer (unsigned char*) to the first byte to be reordered. WARNING: This argument is not checked for NULL. |
amount | The number of bytes to be reordered. |
Referenced by LSB_native(), MSB_native(), and reorder_bytes().
void PIRL::reorder_bytes | ( | unsigned char * | data, |
const unsigned long | groups, | ||
const unsigned int | size | ||
) |
Reorders data bytes in groups.
The byte groups are mirrored, in place. The first group is swapped with the last group, the second group is swapped with the next-to-last group, etc. until all group pairs have been swapped. The bytes within each group are not swapped; they stay in the same order.
data | A pointer (unsigned char*) to the first byte to be reordered. |
groups | The number of groups to be reordered. |
size | The number of bytes per group. |
References reorder_bytes().
void PIRL::swap_bytes | ( | unsigned char * | data, |
const unsigned int | groups, | ||
const unsigned int | size | ||
) |
Swap groups of data bytes.
The byte groups are swapped in place. The first byte of each group is swapped with the last byte in the group, the second byte is swapped with the next-to-last byte in the group, etc. until all bytes within the group have been reorderd. All byte groups are swapped in the same way.
data | A pointer (unsigned char*) to the first byte to be reordered. |
groups | The number of groups to be reordered. If this is zero nothing is done. |
size | The number of bytes per group. If this is less than two nothing is done. |
bool PIRL::high_endian_host | ( | ) | [inline] |
Tests if the host system is high-endian.
References host_is_high_endian().
Referenced by PIRL::Binary_IO::get_3(), PIRL::Binary_IO::IO(), and PIRL::Binary_IO::put_3().
bool PIRL::big_endian_host | ( | ) | [inline] |
Tests if the host system is big-endian.
References host_is_high_endian().
bool PIRL::low_endian_host | ( | ) | [inline] |
Tests if the host system is low-endian.
References host_is_high_endian().
Referenced by PIRL::Binary_IO::IO().
bool PIRL::little_endian_host | ( | ) | [inline] |
Tests if the host system is little-endian.
References host_is_high_endian().
T& PIRL::MSB_native | ( | T & | value ) |
A MSB (high-endian) data value is coerced to/from native byte order.
If the host system is high-endian the data is left unchanged; otherwise, it is reordered. Therefore, if the argument value is in MSB order the result is in native order; it the argument value is in native order the result in in MSB order.
N.B.: The data value is reordered in place. Make a copy first if the original datum is to remain unchanged; e.g.:
int tmp_value, value = 1;
cout << MSB_value (tmp_value = value)
<< " = MSB_value (" << value << ')' << endl;
value | A datum to be coerced to MSB byte order. The datum should be a primitive type, otherwise the results are undefined. |
References host_is_high_endian(), and reorder_bytes().
T& PIRL::LSB_native | ( | T & | value ) |
A LSB (low-endian) data value is coerced to/from native byte order.
If the host system is low-endian the data is left unchanged; otherwise, it is reordered. Therefore, if the argument value is in LSB order the result is in native order; it the argument value is in native order the result in in LSB order.
N.B.: The data value is reordered in place. Make a copy first if the original datum is to remain unchanged; e.g.:
int tmp_value, value = 1;
cout << LSB_value (tmp_value = value)
<< " = LSB_value (" << value << ')' << endl;
value | A datum to be coerced to LSB byte order. The datum should be a primitive type, otherwise the results are undefined. |
References host_is_high_endian(), and reorder_bytes().
bool PIRL::file_exists | ( | const std::string & | pathname ) |
Test if a file exists at a pathname.
pathname | The filesystem pathname to test. |
Referenced by file_is_readable(), and file_is_writeable().
bool PIRL::file_is_normal | ( | const std::string & | pathname ) |
Test if a file at a pathname is a normal file.
pathname | The pathname to test. |
References S_ISREG.
bool PIRL::file_is_directory | ( | const std::string & | pathname ) |
Test if a file at a pathname is a directory.
pathname | The pathname to test. |
References S_ISDIR.
bool PIRL::file_is_link | ( | const std::string & | pathname ) |
Test if a file at a pathname is a link file.
pathname | The pathname to test. |
References file_extension(), and S_ISLNK.
off_t PIRL::file_size | ( | const std::string & | pathname ) |
Get the size of a file.
N.B.: For MS/Windows a directory always has a file size of zero.
pathname | The pathname to the file. |
bool PIRL::file_is_absolute | ( | const std::string & | pathname ) |
Test if a pathname is an absolute pathname.
An absolute pathname begins with the FILE_PATHNAME_DELIMITER character.
pathname | The pathname to test. |
References FILE_PATHNAME_DELIMITER, PATHNAME_DELIMITER_UNIX, and PATHNAME_DELIMITER_WIN32.
Referenced by file_directory_pathname(), and file_pathname().
std::string & PIRL::clean_pathname | ( | std::string & | pathname ) |
Clean a pathname of redundant segments.
All sequences of multiple FILE_PATHNAME_DELIMITER characters are replaced with a single delimiter. All sequences of FILE_PATHNAME_DELIMITER-'.'-FILE_PATHNAME_DELIMITER characters are replaced with a single delimiter. Any trailing FILE_PATHNAME_DELIMITER is removed.
pathname | The pathname from which to obtain the extension. |
References FILE_PATHNAME_DELIMITER.
Referenced by file_directory_pathname(), and file_pathname().
std::string PIRL::CWD | ( | ) |
Get the current working directory of the process.
This is a convenience function for the system getcwd function.
runtime_error | If the current working directory can not be obtained. |
References Files_ID.
Referenced by file_directory_pathname(), and file_pathname().
std::string PIRL::file_pathname | ( | const std::string & | filename ) |
Get the full pathname for a filename.
If the filename is relative the current working directory of the process is prepended.
The directory pathname is cleaned before it is returned.
filename | The filename for which to obtain an absolute pathname. |
runtime_error | If the current working directory can not be obtained. |
References clean_pathname(), CWD(), file_is_absolute(), and FILE_PATHNAME_DELIMITER.
std::string PIRL::file_pathname | ( | const std::string & | directory, |
const std::string & | filename | ||
) |
Get the full pathname for a filename.
If the filename is relative the directory is prepended. If the directory is relative the current working directory of the process is prepended to it.
The directory pathname is cleaned before it is returned.
directory | The directory to prepend to the filename if it is not an absolute pathname. |
filename | The filename for which to obtain an absolute pathname. |
runtime_error | If the current working directory can not be obtained. |
References clean_pathname(), CWD(), file_is_absolute(), and FILE_PATHNAME_DELIMITER.
std::string PIRL::file_directory | ( | const std::string & | pathname ) |
Get the leading directory portion of a pathname.
The leading directory portion of a pathname is that substring preceding the last FILE_PATHNAME_DELIMITER, or the empty string if it does not contain the delimiter. N.B.: If the pathname contains only one delimiter that is the first character, then the leading directory pathname is the delimiter (i.e. the filesystem root).
pathname | The pathname from which to obtain the directory pathname. |
References FILE_PATHNAME_DELIMITER.
Referenced by file_directory_pathname().
std::string PIRL::file_directory_pathname | ( | const std::string & | pathname ) |
Get the leading directory pathname portion of a pathname.
The leading directory portion of the pathname is obtained. If it is not an absolute pathname the current working directory of the process is prepended.
The directory pathname is cleaned before it is returned.
pathname | The pathname from which to obtain the directory pathname. |
runtime_error | If the current working directory can not be obtained. |
References clean_pathname(), CWD(), file_directory(), file_is_absolute(), and FILE_PATHNAME_DELIMITER.
std::string PIRL::file_name | ( | const std::string & | pathname ) |
Get the final name portion of a pathname.
The final name portion of a pathname is that substring following the last FILE_PATHNAME_DELIMITER, or the entire string if it does not contain the delimiter.
pathname | The pathname from which to obtain the file's name. |
References FILE_PATHNAME_DELIMITER.
std::string PIRL::file_basename | ( | const std::string & | pathname ) |
Get the basename of a file's pathname.
The basename is that portion of the path preceeding the last FILE_EXTENSION_DELIMITER; or the entire string if there it does not contain the delimiter. N.B.: Any directory segments of the pathname are retained in the basename; these can be removed using the file_name method.
pathname | The pathname from which to obtain the basename. |
References FILE_EXTENSION_DELIMITER.
std::string PIRL::file_extension | ( | const std::string & | pathname ) |
Get a file's extension.
The extension is that portion of the path following the last FILE_EXTENSION_DELIMITER. This will be the empty string if no extension is present or the pathname ends with the delimiter.
pathname | The pathname from which to obtain the extension. |
References FILE_EXTENSION_DELIMITER.
Referenced by file_is_link().
bool PIRL::file_is_readable | ( | const std::string & | pathname ) |
Test if a file at a pathname is readable.
Readability is determined by the system's access method. The file must be readable by the real ID of the process.
pathname | The pathname to test. |
runtime_error | If the file attributes can not be obtained (MS/Windows only). |
References file_exists(), GID(), and UID().
bool PIRL::file_is_writeable | ( | const std::string & | pathname ) |
Test if a file at a pathname is writeable.
Writeability is determined by the system's access method. The file must be writeable by the real ID of the process.
pathname | The pathname to test. |
runtime_error | If the file attributes can not be obtained (MS/Windows only). |
References file_exists(), GID(), and UID().
std::string PIRL::home_directory_pathname | ( | ) |
Get the user's home directory pathname.
runtime_error | If the user info can not be obtained. |
std::string PIRL::username | ( | ) |
Get the effective username.
runtime_error | If the user info can not be obtained (UNIX only). |
unsigned int PIRL::UID | ( | ) |
Get the effective user ID.
Referenced by file_is_readable(), and file_is_writeable().
unsigned int PIRL::GID | ( | ) |
Get the effective group ID.
Referenced by file_is_readable(), and file_is_writeable().
std::string PIRL::hostname | ( | ) |
Get the name of the host system.
const char * PIRL::Files_ID = "PIRL::Files ($Revision: 2.4 $ $Date: 2010/11/21 20:33:26 $)" |
Module identification name with source code version and date.
Referenced by CWD().
const char PIRL::FILE_PATHNAME_DELIMITER = PATHNAME_DELIMITER |
Host filesystem pathname delimiter ('/').
Referenced by clean_pathname(), file_directory(), file_directory_pathname(), file_is_absolute(), file_name(), and file_pathname().
const char PIRL::FILE_EXTENSION_DELIMITER = EXTENSION_DELIMITER |
Filename extension delimiter ('.').
Referenced by file_basename(), and file_extension().