The namespace containing all the "helper" functions in the C++ code. More...
Classes | |
class | argumentinvalid_error |
Exception for arguments that are invalid. More... | |
class | argumentnull_error |
Exception for arguments that are null. More... | |
class | DateTime |
Represents a timestamp composed of a date and a time encoded in a time_t value. Provides ways of getting the current time and to format the time in a string. More... | |
Functions | |
bool | checkforkey () |
Determine if a key has been pressed. | |
void | disableinputecho () |
Disable echoing input until enableinputecho() is called. | |
void | enableinputecho () |
Enable echoing input, which should be the default mode. Call this only after calling disableinputecho();. | |
void | setcursorposition (int row, int column) |
Move the text cursor to the specified screen coordinates. | |
void | getcursorposition (int *row, int *column) |
Retrieve the current cursor position in the console window. | |
void | enableVTMode () |
On Windows, enable the virtual terminal processing mode on the Console's output handle. On all other operating systems, this function does nothing. | |
std::string | formatstring (const char *fmt,...) |
Use the given string and arguments to return a buffer containing the formatted string. The format and arguments follow the printf() functionality. | |
struct tm * | makelocaltime (const time_t *time, struct tm *timestruct) |
Convert the given time to local time. | |
int | readkey () |
Read a key from the keyboard, blocking if no key is pressed. | |
std::string | Replace (const std::string &s, const char *str1, const char *str2, bool bCaseInsensitive=false) |
Replace all occurrences of narrow string str1 with narrow string str2 in s . If str2 is empty then all matches to str1 are effectively removed from the string. | |
std::string | Replace (const std::string &s, char c1, char c2, bool bCaseInsensitive=false) |
Replace all occurrences of narrow character c1 with narrow character c2 in s . If c2 is empty then all matches to str1 are effectively removed from the string. | |
std::wstring | Replace (const std::wstring &s, wchar_t c1, wchar_t c2, bool bCaseInsensitive=false) |
Replace all occurrences of wide character c1 with wide character c2 in s . If c2 is empty then all matches to str1 are effectively removed from the string. | |
std::wstring | Replace (const std::wstring &s, const wchar_t *str1, const wchar_t *str2, bool bCaseInsensitive=false) |
Replace all occurrences of wide string str1 with wide string str2 in s . If str2 is empty then all matches to str1 are effectively removed from the string. | |
void | sleep (int milliseconds) |
Sleep for the specified number of milliseconds. Does not return until after the sleep period. | |
std::vector< std::string > | split (const char *pszString, const char *splitChars=" ") |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list. | |
std::vector< std::string > | split (const std::string &szString, const std::string &splitChars=" ") |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list. | |
std::vector< std::wstring > | split (const wchar_t *pszString, const wchar_t *splitChars=L" ") |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list. | |
std::vector< std::wstring > | split (const std::wstring &szString, const std::wstring &splitChars=L" ") |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list. | |
int | stricmp (const char *first, const char *second) |
Compare two strings in a case-insensitive manner to determine their alphabetical order relative to each other. | |
int | stricmp (const std::string &first, const std::string &second) |
Compare two strings in a case-insensitive manner to determine their alphabetical order relative to each other. | |
char * | strstri (const char *s1, const char *s2) |
Do case-insensitive search for string 2 (s2 ) in string 1 (s1 ). Similar to the C library's strstr(). | |
std::string | titlecase (const std::string &s) |
Convert the first word (or only word) in the given string to lowercase then make the first letter uppercase. It does not touch any of the other words after the first. | |
std::string | uint32_to_binary (uint32_t number) |
Function to convert a 32-bit unsigned integer into a string representation containing all 32 bits. | |
wchar_t * | wcsstri (const wchar_t *s1, const wchar_t *s2) |
Do case-insensitive search for string 2 (s2 ) in string 1 (s1 ). Similar to the C library's wcsstr(). | |
The namespace containing all the "helper" functions in the C++ code.
bool checkforkey | ( | ) |
Determine if a key has been pressed.
Determine if a key has been pressed on the keyboard.
Definition at line 46 of file checkforkey.cpp.
References kbhit().
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
void disableinputecho | ( | ) |
Disable echoing input until enableinputecho() is called.
Definition at line 118 of file cursor.cpp.
References _disableInputEcho(), and inputEchoDisabled.
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
void enableinputecho | ( | ) |
Enable echoing input, which should be the default mode. Call this only after calling disableinputecho();.
Definition at line 129 of file cursor.cpp.
References _enableInputEcho(), and inputEchoDisabled.
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
void enableVTMode | ( | ) |
On Windows, enable the virtual terminal processing mode on the Console's output handle. On all other operating systems, this function does nothing.
Definition at line 85 of file enablevtmode.cpp.
References enableVTMode().
Referenced by enableVTMode(), and main().
std::string formatstring | ( | const char * | fmt, |
... | |||
) |
Use the given string and arguments to return a buffer containing the formatted string. The format and arguments follow the printf() functionality.
fmt | String containing formatting codes as used with the printf() function. |
Definition at line 17 of file formatstring.cpp.
Referenced by MessageWindow::_HandleButtonDownMessage(), MessageWindow::_HandleButtonUpMessage(), MessageWindow::_HandleCloseMessage(), Interpreter_Class::_InterpretToken(), UserGroupMediator::AddUserToGroup(), DataReaderWriter::BufferToString(), DesignPatternExamples_cpp::Command_Exercise(), Strategy_SortEntries_ClassFactory::Create(), DesignPatternExamples_cpp::Decorator_Exercise(), Real_Class::DoWork(), DesignPatternExamples_cpp::Flyweight_Exercise(), DesignPatternExamples_cpp::LoggerHelpers::FormatLogLine(), Composite_FileAccess::GetEntry(), UserGroupMediator::GetGroupsWithUser(), UserGroupMediator::GetUsersInGroup(), DesignPatternExamples_cpp::Interpreter_Exercise(), UserGroupMediator::IsUserInGroup(), DesignPatternExamples_cpp::Iterator_Exercise(), DesignPatternExamples_cpp::Mediator_Exercise(), DesignPatternExamples_cpp::Memento_Exercise(), DesignPatternExamples_cpp::NullObject_Exercise(), ObserverForDecimal::NumberChanged(), ObserverForHexaDecimal::NumberChanged(), ObserverForBinary::NumberChanged(), DesignPatternExamples_cpp::Observer_Exercise(), Visitor_Shop::PickupOrder(), Visitor_Shop::PlaceOrder(), DesignPatternExamples_cpp::Proxy_Exercise(), UserGroupMediator::RemoveUserFromAllGroups(), UserGroupMediator::RemoveUserFromGroup(), WhiteBackgroundDecorator::Render(), UnderlineDecorator::Render(), RedForegroundDecorator::Render(), MoveCommand::Show(), Strategy_ShowEntries_Class::ShowEntries(), Command::ToString(), HandlerChain::ToString(), MessagePosition::ToString(), Message::ToString(), WindowRectangle::ToString(), MessageWindow::ToString(), EntryInformation::ToString(), and DesignPatternExamples_cpp::Visitor_Exercise().
void getcursorposition | ( | int * | row, |
int * | column | ||
) |
Retrieve the current cursor position in the console window.
row | Returns the row index from the top, starting at 0. |
column | Returns the column index from the left, starting at 0. |
Definition at line 149 of file cursor.cpp.
References _countof, _disableInputEcho(), _enableInputEcho(), inputEchoDisabled, and split().
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
struct tm * makelocaltime | ( | const time_t * | time, |
struct tm * | timestruct | ||
) |
Convert the given time to local time.
Hides the differences between multiple C++ library implementations.
time | Pointer to the time_t object representing the time to convert. |
timestruct | Pointer to a struct tm in which to put the results of converting to local time. |
This is an example of a function acting as an adapter. The rest of the program just wants to convert a time stamp to local time and doesn't want to know about the differences between implementations of the C++ library.
Definition at line 17 of file makelocaltime.cpp.
Referenced by DateTime::ToString().
int readkey | ( | ) |
Read a key from the keyboard, blocking if no key is pressed.
Definition at line 17 of file readkey.cpp.
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
std::string Replace | ( | const std::string & | s, |
char | c1, | ||
char | c2, | ||
bool | bCaseInsensitive = false |
||
) |
Replace all occurrences of narrow character c1
with narrow character c2
in s
. If c2
is empty then all matches to str1
are effectively removed from the string.
s | String to search |
c1 | Character to replace |
c2 | Character to replace with |
bCaseInsensitive | true if to perform case-insensitive search; otherwise, use case-sensitive search |
Definition at line 140 of file replace.cpp.
References Replace().
std::string Replace | ( | const std::string & | s, |
const char * | str1, | ||
const char * | str2, | ||
bool | bCaseInsensitive = false |
||
) |
Replace all occurrences of narrow string str1
with narrow string str2
in s
. If str2
is empty then all matches to str1
are effectively removed from the string.
s | String to search |
str1 | String to replace |
str2 | String to replace with |
bCaseInsensitive | true if to perform case-insensitive search; otherwise, use case-sensitive search |
Definition at line 47 of file replace.cpp.
References strstri().
Referenced by Composite_FileAccess::GetEntry(), Program::Help(), and Replace().
std::wstring Replace | ( | const std::wstring & | s, |
const wchar_t * | str1, | ||
const wchar_t * | str2, | ||
bool | bCaseInsensitive = false |
||
) |
Replace all occurrences of wide string str1
with wide string str2
in s
. If str2
is empty then all matches to str1
are effectively removed from the string.
s | String to search |
str1 | String to replace |
str2 | String to replace with |
bCaseInsensitive | true if to perform case-insensitive search; otherwise, use case-sensitive search |
Definition at line 45 of file replacew.cpp.
References wcsstri().
std::wstring Replace | ( | const std::wstring & | s, |
wchar_t | c1, | ||
wchar_t | c2, | ||
bool | bCaseInsensitive = false |
||
) |
Replace all occurrences of wide character c1
with wide character c2
in s
. If c2
is empty then all matches to str1
are effectively removed from the string.
s | String to search |
c1 | Character to replace |
c2 | Character to replace with |
bCaseInsensitive | true if to perform case-insensitive search; otherwise, use case-sensitive search |
Definition at line 135 of file replacew.cpp.
References Replace().
void setcursorposition | ( | int | row, |
int | column | ||
) |
Move the text cursor to the specified screen coordinates.
row | Row index from top, starting at 0. |
column | Column index from left, starting at 0 |
Definition at line 140 of file cursor.cpp.
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
void sleep | ( | int | milliseconds | ) |
Sleep for the specified number of milliseconds. Does not return until after the sleep period.
milliseconds | Number of milliseconds to sleep. |
Definition at line 15 of file sleep.cpp.
Referenced by DesignPatternExamples_cpp::Flyweight_Exercise().
std::vector< std::string > split | ( | const char * | pszString, |
const char * | splitChars = " " |
||
) |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list.
pszString | The string to split. |
splitChars | The character or characters to split on. This parameter is treated as a list of characters on which to split the string. |
Definition at line 13 of file split.cpp.
Referenced by Composite_FileAccess::_FindEntry(), getcursorposition(), and split().
std::vector< std::string > split | ( | const std::string & | szString, |
const std::string & | splitChars = " " |
||
) |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list.
szString | The string to split. |
splitChars | The character or characters to split on. This parameter is treated as a list of characters on which to split the string. |
Definition at line 39 of file split.cpp.
References split().
std::vector< std::wstring > split | ( | const std::wstring & | szString, |
const std::wstring & | splitChars = L" " |
||
) |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list.
szString | The string to split. |
splitChars | The character or characters to split on. This parameter is treated as a list of characters on which to split the string. |
Definition at line 38 of file splitw.cpp.
References split().
std::vector< std::wstring > split | ( | const wchar_t * | pszString, |
const wchar_t * | splitChars = L" " |
||
) |
Split the given string into a list of strings given the character on which to split. If the split character does not appear, return the original string as the first entry in the list.
pszString | The string to split. |
splitChars | The character or characters to split on. This parameter is treated as a list of characters on which to split the string. |
Definition at line 12 of file splitw.cpp.
int stricmp | ( | const char * | first, |
const char * | second | ||
) |
Compare two strings in a case-insensitive manner to determine their alphabetical order relative to each other.
first | First string compare. |
second | Second string to compare |
Definition at line 16 of file stricmp.cpp.
Referenced by GroupList::GroupNames(), and stricmp().
int stricmp | ( | const std::string & | first, |
const std::string & | second | ||
) |
Compare two strings in a case-insensitive manner to determine their alphabetical order relative to each other.
first | First string compare. |
second | Second string to compare |
Definition at line 59 of file stricmp.cpp.
References stricmp().
char * strstri | ( | const char * | s1, |
const char * | s2 | ||
) |
Do case-insensitive search for string 2 (s2
) in string 1 (s1
). Similar to the C library's strstr().
s1 | Pointer to the string to search |
s2 | Pointer to the string to search for |
Definition at line 35 of file strstri.cpp.
Referenced by Replace().
std::string titlecase | ( | const std::string & | s | ) |
Convert the first word (or only word) in the given string to lowercase then make the first letter uppercase. It does not touch any of the other words after the first.
Note that this is not locale-sensitive.
s | A string to work on. |
Definition at line 11 of file titlecase.cpp.
Referenced by Interpreter_Class::Interpret().
std::string uint32_to_binary | ( | uint32_t | number | ) |
Function to convert a 32-bit unsigned integer into a string representation containing all 32 bits.
Need this since C does not normally provide a printf() converter to binary.
number | The number to convert to a string representation in binary. |
Definition at line 18 of file uint32_to_binary.cpp.
Referenced by ObserverForBinary::NumberChanged().
wchar_t * wcsstri | ( | const wchar_t * | s1, |
const wchar_t * | s2 | ||
) |
Do case-insensitive search for string 2 (s2
) in string 1 (s1
). Similar to the C library's wcsstr().
s1 | Pointer to the string to search |
s2 | Pointer to the string to search for |
Definition at line 30 of file wcsstri.cpp.
Referenced by Replace().