Two files utilities.hpp and utilities_impl.cpp represent a collection of classes that I use for many years to build different ISAPI extensions and filters, therefore they capable to generate HTML output to simplify access to a remote server for debugging, tracing and statistical analysis.
Sample of generating information on the IIS server:
//
// generating full information on server: domain, time-zone, locals, memory, CPU(s) , etc
//
std::ostringstream htm;
htm << "<HTML><HEAD><TITLE>Infromation on HTTP server</TITLE></HEAD>"
"</BODY><H1>Infromation on HTTP server</H1>";
ThisComputer::Information(htm) ;
//
// information on this DLL (either ISAPI filter or extension): time of creation,
// modification, size, and its version information
//
htm << FileVersion(::AfxGetResourceHandle()).getFileVersionAsHtml()
<< FileInformation(::AfxGetResourceHandle()).getFileInformationAsHtml()
<< "</BODY></HTML>";
std::string result(htm.str()); // get the result as string
Here is a short description what is in there (for more info see the code, C++ is self descriptive, is not it):
| Declaration | Description |
|---|---|
|
class ThisComputer; class FileInformation; class FileVersion; class InternetExplorer; | Information on host computer (OS version, time zone, local, user, domain, name of computer, CPU(s), network adapters, physical and logical devices, memory), information on a file, a version of file (such as DLL, and EXE), information on the Internet Explorer. Capable to generate HTML into output stream. |
|
class CRuntime_error; class CSeExceptionsTranslator; |
CRuntime_error is a class to convert common Win32 and VC errors (std::*_error, std::exception, _com_error, HRESULT, ::GetLastError, CException, and so on). CSeExceptionsTranslator is a translator of the Win32 SE exceptions into CRuntime_error. On constructor hooks up SE, on destructor restores the original one. Does not hook the debug interrupts in DEBUG version. Catch everything into one class. |
|
class FileTime; class SystemTime; | wrappers on SYSTEMTIME, FILETIME. |
|
class string_pair_parser; typedef string_pair_parser<'&', '=', map<string, string> > HTTP_POST_data; typedef string_pair_parser<'&', '=', map<string, string, char_less_than_ignore_case> > HTTP_query_string; typedef string_pair_parser<'\n', ':', map<string, string, char_less_than_ignore_case> > HTTP_headers; template< char D=';'> class HTTP_cookie_base; class HTTP_cookie; class HTTP_dictinary_cookie; |
string_pair_parser parses a string of key-value separated by separator and puts them in container (for example map or multimap). Everything else is typedefed from it:
|
|
class EventStream; class OutputDebugStream; class TraceStream; |
C++ stream complain ::OutputDebugString, ::ReportEvent, and tracer. For example, to put debug string in output concole: OutputDebugStream("Line ") <<__LINE__ << ", File " << __FILE__; |
| template<const char=','> struct CSV; | Comma-separted-values format. CSV<'\\'> makes backslash separated format |
|
class char_less_than_ignore_case; class char_equal_ignore_case; class char_less_equal_ignore_case; template<typename E> ichar_traits; | the case-insensitive predicates to compare string, char, and *char, traits to make string nocase. They use std::lexicographical_compare |
|
string& trim_left(string& s); string& trim_right(string& s); string& trim(string& s); | functions to trim string from left and right, they trim out whitespaces "\r\n\t ", and even nul-symbol '\0' if it happens to be in the string |
|
string& make_upper_case(string& s); string& make_lower_case(string& s); | functors to convert english string using ::tolower and ::toupper |
|
string& replace(string& str, const string& find_str, size_t ntimes=-1); | replaces find_str with replace_str ntimes (-1 means as many times as possible) |