string_common.h File Reference


Detailed Description

common algorithms on string like toString() and fromString()

Id
string_common.h,v 1.4 2004/01/07 18:31:13 lecroart Exp

Definition in file string_common.h.

#include "nel/misc/types_nl.h"
#include <cstdio>
#include <cstdarg>

Go to the source code of this file.

Namespaces

namespace  NLMISC

Defines

#define NLMISC_CONVERT_VARGS(_dest, _format, _size)


Define Documentation

#define NLMISC_CONVERT_VARGS _dest,
_format,
_size   ) 
 

Value:

char _cstring[_size]; \
va_list _args; \
va_start (_args, _format); \
int _res = vsnprintf (_cstring, _size-1, _format, _args); \
if (_res == -1 || _res == _size-1) \
{ \
        _cstring[_size-1] = '\0'; \
} \
va_end (_args); \
_dest = _cstring
This macro converts variable arguments into C string (zero terminated string). This function takes care to avoid buffer overflow.

Example:

void MyFunction(const char *format, ...) { string str; NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize); // str contains the result of the conversion } *

Parameters:
_dest string or char* that contains the result of the convertion
_format format of the string, it must be the last argument before the '...'
_size size of the buffer that will contain the C string

Definition at line 70 of file string_common.h.

Referenced by NLMISC::CLog::display(), NLMISC::CLog::displayNL(), NLMISC::CLog::displayRaw(), NLMISC::CLog::displayRawNL(), NLMISC::Exception::Exception(), NLMISC::CLog::forceDisplayRaw(), NLMISC::nlError(), NLMISC::nlFatalError(), NL3D::CTextContextUser::printfAt(), NL3D::CTextContext::printfAt(), NL3D::CTextContextUser::render3D(), NLNET::sendAdminEmail(), NL3D::CTextContextUser::textPush(), NL3D::CTextContext::textPush(), NLMISC::toString(), NLMISC::xmlGenericErrorFuncRead(), and NLMISC::xmlGenericErrorFuncWrite().


Generated on Tue Mar 16 06:43:22 2004 for NeL by doxygen 1.3.6