Various Windows API helpers

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):

DeclarationDescription
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.
template< char sep, char del, class container>
    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:
  • HTTP headers, separated by '\n' and delimited by '=', case insensitive keys
  • HTTP POST data, HTTP QueryString, and HTTP dictionary cookie; they are separated by '&' and delimited by '=', case insensitive key.
  • HTTP cookies separated by ';' and delimited by '=', case insensitive key.
It's possible to parse strings into container with transformation (for example URL::decode). The template has safe functions versus original map/multimap to check if a key is available, it also helps to build a string out of container to generate f.e. HTTP cookie (again with a transformation, which may be URL::encode)
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);
string& trim_to_cpp_string(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,
    const string& rep_str=string(),
    size_t ntimes=-1);
replaces find_str with replace_str ntimes (-1 means as many times as possible)

About me click here (http://home.comcast.net/~GeorgeSalnikov).
Downloads:
  1. string_t.h
  2. string_t.cpp console test for the ComBSTRing.
  3. utilities.hpp and utilities_impl.cpp Windows API extensions.