OW_NAMESPACE::SafeCString Namespace Reference


Namespaces

namespace  Impl

Functions

 OW_DEFINE_EXCEPTION (Overflow)
char * str_dup (char const *s)
 Like std::strdup, except that new is used to allocate memory.
char * str_dup_nothrow (char const *s)
 Like std::strdup, except that no-throw new is used to allocate memory and NULL is returned on allocation failure.
char const * nonull (char const *s)
 RETURNS: s if s is nonnull, otherwise returns empty string.
char * strcpy_trunc (char *dst, std::size_t dstsize, char const *src)
 PROMISE: copies the first n = min(strlen(src), dstsize - 1) characters of C-string src to dst, null-terminating the result.
char * strcpy_trunc (char *dst, std::size_t dstsize, char const *src, std::size_t srclen)
 PROMISE: copies the first n = min(strlen(src), srclen, dstsize - 1) characters of C-string src to dst, null-terminating the result.
template<std::size_t N>
char * strcpy_trunc (char(&dst)[N], char const *src)
 A variant of strcpy_trunc that infers the destination buffer size.
template<std::size_t N>
char * strcpy_trunc (char(&dst)[N], char const *src, std::size_t srclen)
 A variant of strcpy_trunc that infers the destination buffer size.
template<std::size_t N>
std::size_t strcpy_to_pos_trunc (char(&dst)[N], std::size_t pos, char const *src)
 Like strcpy_trunc, but the destination is the subarray dst[pos.
template<std::size_t N>
std::size_t strcpy_to_pos_trunc (char(&dst)[N], std::size_t pos, char const *src, std::size_t srclen)
 Like strcpy_trunc, but the destination is the subarray dst[pos.
 OW_DECLARE_EXCEPTION (Overflow)
char * strcpy_check (char *dst, std::size_t dstsize, char const *src)
 PROMISE: copies the first n = min(strlen(src), dstsize - 1) chars of the C-string src to dst and appends a terminating ''.
char * strcpy_check (char *dst, std::size_t dstsize, char const *src, std::size_t srclen)
 PROMISE: copies the first min(n, dstsize - 1) chars of the C-string src to dst, where n = min(strlen(src), srclen), and appends a terminating ''.
template<std::size_t N>
char * strcpy_check (char(&dst)[N], char const *src)
 A variant of strcpy_check that infers the destination buffer size.
template<std::size_t N>
char * strcpy_check (char(&dst)[N], char const *src, std::size_t srclen)
 A variant of strcpy_check that infers the destination buffer size.
template<std::size_t N>
std::size_t strcpy_to_pos_check (char(&dst)[N], std::size_t pos, char const *src)
 Like strcpy_check, but the destination is the subarray dst[pos.
template<std::size_t N>
std::size_t strcpy_to_pos_check (char(&dst)[N], std::size_t pos, char const *src, std::size_t srclen)
 Like strcpy_check, but the destination is the subarray dst[pos.
char * strcat_trunc (char *dst, std::size_t dstsize, char const *src)
 PROMISE: If dst[0.
char * strcat_trunc (char *dst, std::size_t dstsize, char const *src, std::size_t srclen)
 PROMISE: If dst[0.
template<std::size_t N>
char * strcat_trunc (char(&dst)[N], char const *src)
 A variant of strcat_trunc that infers the destination buffer size.
template<std::size_t N>
char * strcat_trunc (char(&dst)[N], char const *src, std::size_t srclen)
 A variant of strcat_trunc that infers the destination buffer size.
char * strcat_check (char *dst, std::size_t dstsize, char const *src)
 PROMISE: If dst[0.
char * strcat_check (char *dst, std::size_t dstsize, char const *src, std::size_t srclen)
 PROMISE: If dst[0.
template<std::size_t N>
char * strcat_check (char(&dst)[N], char const *src)
 A variant of strcat_check that infers the destination buffer size.
template<std::size_t N>
char * strcat_check (char(&dst)[N], char const *src, std::size_t srclen)
 A variant of strcat_check that infers the destination buffer size.
template<typename T1>
std::size_t sprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2>
std::size_t sprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3>
std::size_t sprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3, typename T4>
std::size_t sprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t sprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4, T5 const &x5)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<std::size_t N, typename T1>
std::size_t sprintf_trunc (char(&dst)[N], char const *fmt, T1 const &x1)
 A variant of sprintf_trunc that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2>
std::size_t sprintf_trunc (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2)
 A variant of sprintf_trunc that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3>
std::size_t sprintf_trunc (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3)
 A variant of sprintf_trunc that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3, typename T4>
std::size_t sprintf_trunc (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4)
 A variant of sprintf_trunc that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t sprintf_trunc (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4, T5 const &x5)
 A variant of sprintf_trunc that infers the destination buffer size.
template<typename T1>
std::size_t sprintf_check (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2>
std::size_t sprintf_check (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3>
std::size_t sprintf_check (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3, typename T4>
std::size_t sprintf_check (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t sprintf_check (char *dst, std::size_t dstsize, char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4, T5 const &x5)
 PROMISE: Behaves like sprintf(dst, fmt, .
template<std::size_t N, typename T1>
std::size_t sprintf_check (char(&dst)[N], char const *fmt, T1 const &x1)
 A variant of sprintf_check that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2>
std::size_t sprintf_check (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2)
 A variant of sprintf_check that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3>
std::size_t sprintf_check (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3)
 A variant of sprintf_check that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3, typename T4>
std::size_t sprintf_check (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4)
 A variant of sprintf_check that infers the destination buffer size.
template<std::size_t N, typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t sprintf_check (char(&dst)[N], char const *fmt, T1 const &x1, T2 const &x2, T3 const &x3, T4 const &x4, T5 const &x5)
 A variant of sprintf_check that infers the destination buffer size.
template<typename T1>
std::size_t vprintf_trunc (char *dst, std::size_t dstsize, char const *fmt, va_list ap)
 PROMISE: Behaves like vprintf(dst, fmt, ap) except that output stops at dstsize - 1 characters.
template<std::size_t N>
std::size_t vprintf_trunc (char(&dst)[N], char const *fmt, va_list ap)
 A variant of vprintf_trunc that infers the destination buffer size.
std::size_t vprintf_check (char *dst, std::size_t dstsize, char const *fmt, va_list ap)
 PROMISE: Behaves like vprintf(dst, fmt, ap) except that output stops at dstsize - 1 characters.
template<std::size_t N>
std::size_t vprintf_check (char(&dst)[N], char const *fmt, va_list ap)
 A variant of vprintf_check that infers the destination buffer size.
char * fgets_trunc (char *dst, std::size_t dstsize, FILE *fp)
 PROMISE: Equivalent to std::fgets, except that I/O errors are reported by throwing an exception.
template<std::size_t N>
char * fgets_trunc (char(&dst)[N], FILE *fp)
 A variant of fgets_trunc that infers the destination buffer size.
char * fgets_check (char *dst, std::size_t dstsize, FILE *fp)
 PROMISE: Equivalent to std::fgets, except that I/O errors and truncated lines are reported by throwing an exception.
template<std::size_t N>
char * fgets_check (char(&dst)[N], FILE *fp)
 A variant of fgets_check that infers the destination buffer size.
String fget_string (FILE *fp, std::size_t const max_chars)
 RETURNS: A String created by reading from fp until either EOF or a newline is encountered.

Variables

int const RESULT_TRUNCATED = 0
 Error codes for use with OverflowException class.
int const DEST_UNTERMINATED = 1


Function Documentation

String OW_NAMESPACE::SafeCString::fget_string FILE *  fp,
std::size_t const   max_chars
 

RETURNS: A String created by reading from fp until either EOF or a newline is encountered.

If a newline is found it is included in the return String.

THROWS: OpenWBEM::IOException if there is a read error.

THROWS: OpenWBEM::StringConversionException if neither EOF nor newline is found within max_chars characters. (This is a protection against unreasonably long inputs.)

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::fgets_check char &  dst[N],
FILE *  fp
[inline]
 

A variant of fgets_check that infers the destination buffer size.

Definition at line 769 of file OW_SafeCString.hpp.

References fgets_check().

char* OW_NAMESPACE::SafeCString::fgets_check char *  dst,
std::size_t  dstsize,
FILE *  fp
 

PROMISE: Equivalent to std::fgets, except that I/O errors and truncated lines are reported by throwing an exception.

THROWS: OpenWBEM::IOException if there is a read error.

THROWS: OverflowException if the input line (including terminating '') must be truncated to fit into dstsize chars.

REQUIRES: dst nonnull, fp nonnull, dstsize > 0.

RETURNS: NULL if no characters read because of reaching EOF; dst otherwise.

Referenced by fgets_check().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::fgets_trunc char &  dst[N],
FILE *  fp
[inline]
 

A variant of fgets_trunc that infers the destination buffer size.

Definition at line 745 of file OW_SafeCString.hpp.

References fgets_trunc().

char* OW_NAMESPACE::SafeCString::fgets_trunc char *  dst,
std::size_t  dstsize,
FILE *  fp
 

PROMISE: Equivalent to std::fgets, except that I/O errors are reported by throwing an exception.

THROWS: OpenWBEM::IOException if there is a read error.

REQUIRES: dst nonnull, fp nonnull, dstsize > 0.

RETURNS: NULL if no characters read because of reaching EOF; dst otherwise.

Referenced by fgets_trunc().

char const* OW_NAMESPACE::SafeCString::nonull char const *  s  )  [inline]
 

RETURNS: s if s is nonnull, otherwise returns empty string.

WARNING: Do not deallocate the return value.

Definition at line 27 of file OW_SafeCString.hpp.

OW_NAMESPACE::SafeCString::OW_DECLARE_EXCEPTION Overflow   ) 
 

OW_NAMESPACE::SafeCString::OW_DEFINE_EXCEPTION Overflow   ) 
 

template<std::size_t N, typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4,
T5 const &  x5
 

A variant of sprintf_check that infers the destination buffer size.

Definition at line 669 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<std::size_t N, typename T1, typename T2, typename T3, typename T4>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4
 

A variant of sprintf_check that infers the destination buffer size.

Definition at line 656 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<std::size_t N, typename T1, typename T2, typename T3>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3
 

A variant of sprintf_check that infers the destination buffer size.

Definition at line 644 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<std::size_t N, typename T1, typename T2>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2
 

A variant of sprintf_check that infers the destination buffer size.

Definition at line 622 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<std::size_t N, typename T1>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char &  dst[N],
char const *  fmt,
T1 const &  x1
 

A variant of sprintf_check that infers the destination buffer size.

Definition at line 613 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4,
T5 const &  x5
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 600 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<typename T1, typename T2, typename T3, typename T4>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 582 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<typename T1, typename T2, typename T3>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 564 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<typename T1, typename T2>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 528 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<typename T1>
std::size_t OW_NAMESPACE::SafeCString::sprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 512 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

template<std::size_t N, typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4,
T5 const &  x5
 

A variant of sprintf_trunc that infers the destination buffer size.

Definition at line 493 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<std::size_t N, typename T1, typename T2, typename T3, typename T4>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4
 

A variant of sprintf_trunc that infers the destination buffer size.

Definition at line 480 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<std::size_t N, typename T1, typename T2, typename T3>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3
 

A variant of sprintf_trunc that infers the destination buffer size.

Definition at line 468 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<std::size_t N, typename T1, typename T2>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char &  dst[N],
char const *  fmt,
T1 const &  x1,
T2 const &  x2
 

A variant of sprintf_trunc that infers the destination buffer size.

Definition at line 446 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<std::size_t N, typename T1>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char &  dst[N],
char const *  fmt,
T1 const &  x1
 

A variant of sprintf_trunc that infers the destination buffer size.

Definition at line 437 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<typename T1, typename T2, typename T3, typename T4, typename T5>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4,
T5 const &  x5
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 424 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<typename T1, typename T2, typename T3, typename T4>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3,
T4 const &  x4
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 408 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<typename T1, typename T2, typename T3>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2,
T3 const &  x3
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 392 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<typename T1, typename T2>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1,
T2 const &  x2
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 360 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

template<typename T1>
std::size_t OW_NAMESPACE::SafeCString::sprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
T1 const &  x1
 

PROMISE: Behaves like sprintf(dst, fmt, .

..) except that output stops at dstsize - 1 characters. Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 346 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

char * OW_NAMESPACE::SafeCString::str_dup char const *  s  ) 
 

Like std::strdup, except that new is used to allocate memory.

char* OW_NAMESPACE::SafeCString::str_dup_nothrow char const *  s  ) 
 

Like std::strdup, except that no-throw new is used to allocate memory and NULL is returned on allocation failure.

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcat_check char &  dst[N],
char const *  src,
std::size_t  srclen
[inline]
 

A variant of strcat_check that infers the destination buffer size.

Definition at line 320 of file OW_SafeCString.hpp.

References strcat_check().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcat_check char &  dst[N],
char const *  src
[inline]
 

A variant of strcat_check that infers the destination buffer size.

Definition at line 311 of file OW_SafeCString.hpp.

References strcat_check().

char* OW_NAMESPACE::SafeCString::strcat_check char *  dst,
std::size_t  dstsize,
char const *  src,
std::size_t  srclen
 

PROMISE: If dst[0.

.dstsize-1] contains a '', appends to C-string dst the first min(N, dstsize - 1 - strlen(dst)) characters of C-string src, where N = min(strlen(src), srclen), and null terminates the result.

THROWS: OverflowException with getErrorCode() == DEST_UNTERMINATED if dst[0..dstsize-1] contains no ''.

THROWS: OverflowException with getErrorCode() == RESULT_TRUNCATED if strlen(dst) + N >= dstsize.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least srclen characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' of the resulting C-string.

char* OW_NAMESPACE::SafeCString::strcat_check char *  dst,
std::size_t  dstsize,
char const *  src
 

PROMISE: If dst[0.

.dstsize-1] contains a '', appends to C-string dst the first min(strlen(src), dstsize - 1 - strlen(dst)) characters of C-string src and null terminates the result.

THROWS: OverflowException with getErrorCode() == DEST_UNTERMINATED if dst[0..dstsize-1] contains no ''.

THROWS: OverflowException with getErrorCode() == RESULT_TRUNCATED if strlen(dst) + strlen(src) >= dstsize.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' of the resulting C-string.

Referenced by strcat_check().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcat_trunc char &  dst[N],
char const *  src,
std::size_t  srclen
[inline]
 

A variant of strcat_trunc that infers the destination buffer size.

Definition at line 253 of file OW_SafeCString.hpp.

References strcat_trunc().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcat_trunc char &  dst[N],
char const *  src
[inline]
 

A variant of strcat_trunc that infers the destination buffer size.

Definition at line 244 of file OW_SafeCString.hpp.

References strcat_trunc().

char* OW_NAMESPACE::SafeCString::strcat_trunc char *  dst,
std::size_t  dstsize,
char const *  src,
std::size_t  srclen
 

PROMISE: If dst[0.

.dstsize-1] contains a '', appends to C-string dst the first min(strlen(src), srclen, dstsize - 1 - strlen(dst)) characters of C-string src, and null terminates the result.

THROWS: OverflowException if dst[0..dstsize-1] contains no ''.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least srclen characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' of the resulting C-string

char* OW_NAMESPACE::SafeCString::strcat_trunc char *  dst,
std::size_t  dstsize,
char const *  src
 

PROMISE: If dst[0.

.dstsize-1] contains a '', appends to C-string dst the first min(strlen(src), dstsize - 1 - strlen(dst)) characters of C-string src, and null terminates the result.

THROWS: OverflowException if dst[0..dstsize-1] contains no ''.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' of the resulting C-string.

Referenced by strcat_trunc().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcpy_check char &  dst[N],
char const *  src,
std::size_t  srclen
[inline]
 

A variant of strcpy_check that infers the destination buffer size.

Definition at line 169 of file OW_SafeCString.hpp.

References strcpy_check().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcpy_check char &  dst[N],
char const *  src
[inline]
 

A variant of strcpy_check that infers the destination buffer size.

Definition at line 160 of file OW_SafeCString.hpp.

References strcpy_check().

char* OW_NAMESPACE::SafeCString::strcpy_check char *  dst,
std::size_t  dstsize,
char const *  src,
std::size_t  srclen
 

PROMISE: copies the first min(n, dstsize - 1) chars of the C-string src to dst, where n = min(strlen(src), srclen), and appends a terminating ''.

THROWS: OverflowException if n >= dstsize.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least srclen characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' char.

char* OW_NAMESPACE::SafeCString::strcpy_check char *  dst,
std::size_t  dstsize,
char const *  src
 

PROMISE: copies the first n = min(strlen(src), dstsize - 1) chars of the C-string src to dst and appends a terminating ''.

THROWS: OverflowException if strlen(src) >= dstsize.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least dstsize characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: Pointer to the terminating '' char.

Referenced by strcpy_check(), and strcpy_to_pos_check().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::strcpy_to_pos_check char &  dst[N],
std::size_t  pos,
char const *  src,
std::size_t  srclen
[inline]
 

Like strcpy_check, but the destination is the subarray dst[pos.

.N-1] and the return value is an array index instead of a char *.

Definition at line 191 of file OW_SafeCString.hpp.

References strcpy_check().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::strcpy_to_pos_check char &  dst[N],
std::size_t  pos,
char const *  src
[inline]
 

Like strcpy_check, but the destination is the subarray dst[pos.

.N-1] and the return value is an array index instead of a char *.

Definition at line 179 of file OW_SafeCString.hpp.

References strcpy_check().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::strcpy_to_pos_trunc char &  dst[N],
std::size_t  pos,
char const *  src,
std::size_t  srclen
[inline]
 

Like strcpy_trunc, but the destination is the subarray dst[pos.

.N-1] and the return value is an array index instead of a char *.

Definition at line 104 of file OW_SafeCString.hpp.

References strcpy_trunc().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::strcpy_to_pos_trunc char &  dst[N],
std::size_t  pos,
char const *  src
[inline]
 

Like strcpy_trunc, but the destination is the subarray dst[pos.

.N-1] and the return value is an array index instead of a char *.

Definition at line 92 of file OW_SafeCString.hpp.

References strcpy_trunc().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcpy_trunc char &  dst[N],
char const *  src,
std::size_t  srclen
[inline]
 

A variant of strcpy_trunc that infers the destination buffer size.

Definition at line 82 of file OW_SafeCString.hpp.

References strcpy_trunc().

template<std::size_t N>
char* OW_NAMESPACE::SafeCString::strcpy_trunc char &  dst[N],
char const *  src
[inline]
 

A variant of strcpy_trunc that infers the destination buffer size.

Definition at line 73 of file OW_SafeCString.hpp.

References strcpy_trunc().

char* OW_NAMESPACE::SafeCString::strcpy_trunc char *  dst,
std::size_t  dstsize,
char const *  src,
std::size_t  srclen
 

PROMISE: copies the first n = min(strlen(src), srclen, dstsize - 1) characters of C-string src to dst, null-terminating the result.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least srclen characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: dst + n.

char* OW_NAMESPACE::SafeCString::strcpy_trunc char *  dst,
std::size_t  dstsize,
char const *  src
 

PROMISE: copies the first n = min(strlen(src), dstsize - 1) characters of C-string src to dst, null-terminating the result.

REQUIRE: dst != 0, src != 0, dstsize > 0.

REQUIRE: dst points to an array of at least dstsize characters.

REQUIRE: src points to a null-terminated array of characters or an array of at least dstsize - 1 characters.

REQUIRE: the source and destination character sequences do not overlap.

RETURNS: dst + n.

Referenced by strcpy_to_pos_trunc(), and strcpy_trunc().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::vprintf_check char &  dst[N],
char const *  fmt,
va_list  ap
[inline]
 

A variant of vprintf_check that infers the destination buffer size.

Definition at line 721 of file OW_SafeCString.hpp.

References vprintf_check().

std::size_t OW_NAMESPACE::SafeCString::vprintf_check char *  dst,
std::size_t  dstsize,
char const *  fmt,
va_list  ap
[inline]
 

PROMISE: Behaves like vprintf(dst, fmt, ap) except that output stops at dstsize - 1 characters.

Always outputs a terminating ''.

THROWS: OverflowException if the output had to be truncated.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 710 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_check().

Referenced by vprintf_check().

template<std::size_t N>
std::size_t OW_NAMESPACE::SafeCString::vprintf_trunc char &  dst[N],
char const *  fmt,
va_list  ap
[inline]
 

A variant of vprintf_trunc that infers the destination buffer size.

Definition at line 696 of file OW_SafeCString.hpp.

References vprintf_trunc().

template<typename T1>
std::size_t OW_NAMESPACE::SafeCString::vprintf_trunc char *  dst,
std::size_t  dstsize,
char const *  fmt,
va_list  ap
 

PROMISE: Behaves like vprintf(dst, fmt, ap) except that output stops at dstsize - 1 characters.

Always outputs a terminating ''.

RETURNS: the number of chars output, not including the terminating ''

Definition at line 685 of file OW_SafeCString.hpp.

References OW_NAMESPACE::SafeCString::Impl::nchars_output().

Referenced by vprintf_trunc().


Variable Documentation

int const OW_NAMESPACE::SafeCString::DEST_UNTERMINATED = 1
 

Definition at line 114 of file OW_SafeCString.hpp.

Referenced by strend_checked().

int const OW_NAMESPACE::SafeCString::RESULT_TRUNCATED = 0
 

Error codes for use with OverflowException class.

Definition at line 113 of file OW_SafeCString.hpp.


Generated on Thu Feb 9 09:18:00 2006 for openwbem by  doxygen 1.4.6