# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

common.h File Reference

common algorithms, constants and functions. More...

#include "nel/misc/types_nl.h"
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
#include <unistd.h>
#include <sys/types.h>

Go to the source code of this file.

Namespaces

namespace  NLMISC

Defines

#define NLMISC_CONVERT_VARGS(_dest, _format, _size)
 This macro converts variable arguments into C string (zero terminated string). More...

#define new   NL_NEW


Detailed Description

common algorithms, constants and functions.

Id:
common.h,v 1.51 2002/11/15 16:54:18 lecroart Exp

Definition in file common.h.


Define Documentation

#define new   NL_NEW
 

#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 '...' \param _size size of the buffer that will contain the C string

Definition at line 94 of file common.h.

Referenced by NLMISC::CLog::display, NLMISC::CLog::displayNL, NLMISC::CLog::displayRaw, NLMISC::CLog::displayRawNL, NLMISC::Exception::Exception, NLMISC::CLog::forceDisplayRaw, NL3D::CTextContextUser::printfAt, NL3D::CTextContext::printfAt, NL3D::CTextContextUser::render3D, NL3D::CTextContextUser::textPush, and NL3D::CTextContext::textPush.