cwidget::util Namespace Reference

Miscellaneous utility functions that are not directly related to the core functionality of cwidget. More...


Classes

struct  accumulate_and
 Computes the return-value of the signal via a short-circuiting AND. More...
struct  accumulate_or
 Computes the return-value of the signal via a short-circuiting OR. More...
class  AssertionFailure
 Represents an assertion failure. More...
class  Exception
class  ref_ptr
class  slotarg
 Wraps a slot that may not be present. More...

Typedefs

typedef slotarg< sigc::slot0
< void > > 
slot0arg
 Convenience typedefs for slot arguments that take no parameters and return nothing.

Functions

template<typename T>
slotarg< T > arg (const T &slot)
 Convenience routine to construct a slotarg.
string ssprintf (const char *format,...)
string vssprintf (const char *format, va_list ap)
wstring swsprintf (const wchar_t *format,...)
wstring vswsprintf (const wchar_t *format, va_list ap)
string sstrerror (int errnum)
 Like strerror_r, but handles all memory allocation and returns a C++ string.
bool transcode (const char *s, wstring &out, const char *encoding)
std::wstring transcode (const std::string &s, const char *encoding=NULL, std::wstring(*errf)(int error,const std::wstring &partial,const std::string &input)=NULL)
 Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.
std::wstring transcode (const char *s, const char *encoding=NULL, std::wstring(*errf)(int error,const std::wstring &partial,const std::string &input)=NULL)
 Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.
bool transcode (const wchar_t *s, string &out, const char *encoding)
std::string transcode (const std::wstring &s, const char *encoding=NULL, std::string(*errf)(int error,const std::string &partial,const std::wstring &input)=NULL)
 Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.
std::string transcode (const wchar_t *s, const char *encoding=NULL, std::string(*errf)(int error,const std::string &partial,const std::wstring &input)=NULL)
 Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.
bool transcode (const char *s, std::wstring &out, const char *encoding=NULL)
 Convenience function to convert a multibyte encoding to wide characters.
bool transcode (const std::string &s, std::wstring &out, const char *encoding=NULL)
std::wstring(*) transcode_mbtow_err (int error, const std::wstring &partial, const std::string &input)
 The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.
bool transcode (const wchar_t *s, std::string &out, const char *encoding=NULL)
 Convenience function to convert the native wide character encoding to a multibyte encoding.
bool transcode (const std::wstring &s, std::string &out, const char *encoding=NULL)
std::string(*) transcode_wtomb_err (int error, const std::string &partial, const std::wstring &input)
 The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.

Variables

const int initbufsize = 512
std::string(* transcode_wtomb_err )(int error, const std::string &partial, const std::wstring &input) = default_wtomb_err
 The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.
std::wstring(* transcode_mbtow_err )(int error, const std::wstring &partial, const std::string &input) = default_mbtow_err
 The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.


Detailed Description

Miscellaneous utility functions that are not directly related to the core functionality of cwidget.

Function Documentation

template<typename T>
slotarg<T> cwidget::util::arg ( const T &  slot  )  [inline]

Convenience routine to construct a slotarg.

The purpose of this routine is to allow C++'s local type inference to determine the template parameters to slotarg. It is the recommended way to construct slotarg objects when passing them as parameters to a function.

Template Parameters:
T The slot type that is wrapped by the returned slotarg object.
Parameters:
slot The slot that is to be wrapped.

bool cwidget::util::transcode ( const wchar_t *  s,
std::string &  out,
const char *  encoding = NULL 
)

Convenience function to convert the native wide character encoding to a multibyte encoding.

This is a wrapper around iconv.

Parameters:
s the wide string to encode
out the location to write the multibyte string
encoding the encoding of out; if null or unspecified, the value of LC_CTYPE is used.
Returns:
true if the entire string was successfully transcoded; if transcoding failed, returns false and sets errno.

bool cwidget::util::transcode ( const char *  s,
std::wstring &  out,
const char *  encoding = NULL 
)

Convenience function to convert a multibyte encoding to wide characters.

This is a wrapper around iconv.

Parameters:
s the string to decode
out the location to write the transcoded string
encoding the encoding of s; if null or unspecified, the value of LC_CTYPE is used.
Returns:
true if the entire string was successfully transcoded; if transcoding failed, returns false and sets errno.

std::string cwidget::util::transcode ( const wchar_t *  s,
const char *  encoding = NULL,
std::string(*)(int error, const std::string &partial, const std::wstring &input)  errf = NULL 
)

Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.

This is a wrapper around iconv.

Parameters:
s the string to decode
encoding the encoding of s; if null or unspecified, the value of LC_CTYPE is used.
errf the error handler, or null to use the default handler (transcode_mbtow_err).

References transcode_wtomb_err.

std::string cwidget::util::transcode ( const std::wstring &  s,
const char *  encoding = NULL,
std::string(*)(int error, const std::string &partial, const std::wstring &input)  errf = NULL 
)

Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.

This is a wrapper around iconv.

Parameters:
s the string to decode
encoding the encoding of s; if null or unspecified, the value of LC_CTYPE is used.
errf the error handler, or null to use the default handler (transcode_mbtow_err).

References transcode_wtomb_err.

std::wstring cwidget::util::transcode ( const char *  s,
const char *  encoding = NULL,
std::wstring(*)(int error, const std::wstring &partial, const std::string &input)  errf = NULL 
)

Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.

This is a wrapper around iconv.

Parameters:
s the string to decode
encoding the encoding of s; if null or unspecified, the value of LC_CTYPE is used.
errf the error handler, or null to use the default handler (transcode_mbtow_err).

References transcode_mbtow_err.

std::wstring cwidget::util::transcode ( const std::string &  s,
const char *  encoding = NULL,
std::wstring(*)(int error, const std::wstring &partial, const std::string &input)  errf = NULL 
)

Convenience function to convert a multibyte encoding to wide characters, where the caller doesn't need to directly handle errors.

This is a wrapper around iconv.

Parameters:
s the string to decode
encoding the encoding of s; if null or unspecified, the value of LC_CTYPE is used.
errf the error handler, or null to use the default handler (transcode_mbtow_err).

References transcode_mbtow_err.

std::wstring(*) cwidget::util::transcode_mbtow_err ( int  error,
const std::wstring &  partial,
const std::string &  input 
)

The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.

The default handler just returns "partial".

std::string(*) cwidget::util::transcode_wtomb_err ( int  error,
const std::string &  partial,
const std::wstring &  input 
)

The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.

The default handler just returns "partial".


Variable Documentation

std::wstring(* cwidget::util::transcode_mbtow_err)(int error, const std::wstring &partial, const std::string &input) ( int  error,
const std::wstring &  partial,
const std::string &  input 
) = default_mbtow_err

The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.

The default handler just returns "partial".

Referenced by transcode().

std::string(* cwidget::util::transcode_wtomb_err)(int error, const std::string &partial, const std::wstring &input) ( int  error,
const std::string &  partial,
const std::wstring &  input 
) = default_wtomb_err

The error handler for converting multibyte strings to wide strings: it is passed a partially-decoded string and the error code, and its return value becomes the return value of the function.

The default handler just returns "partial".

Referenced by transcode().


Generated on Sat Jun 12 14:51:03 2010 for cwidget by  doxygen 1.5.6