command.h File Reference


Detailed Description

Management of runtime command line processing

Id
command.h,v 1.28 2004/01/15 17:27:03 lecroart Exp

Definition in file command.h.

#include "nel/misc/types_nl.h"
#include <string>
#include <map>
#include <vector>
#include <istream>
#include "nel/misc/stream.h"
#include "nel/misc/config_file.h"
#include "nel/misc/log.h"

Go to the source code of this file.

Namespaces

namespace  NLMISC

Defines

#define NLMISC_COMMAND(__name, __help, __args)


Define Documentation

#define NLMISC_COMMAND __name,
__help,
__args   ) 
 

Value:

struct __name##Class: public NLMISC::ICommand \
{ \
        __name##Class() : NLMISC::ICommand(#__name,__help,__args) { } \
        virtual bool execute(const std::vector<std::string> &args, NLMISC::CLog &log, bool quiet, bool human); \
}; \
__name##Class __name##Instance; \
bool __name##Class::execute(const std::vector<std::string> &args, NLMISC::CLog &log, bool quiet, bool human)
Create a function that can be call in realtime.

Example:

// I want to create a function that compute the square of the parameter and display the result NLMISC_COMMAND(square,"display the square of the parameter","<value>") { // check args, if there s not the right number of parameter, return bad if(args.size() != 1) return false; // get the value uint32 val = atoi(args[0].c_str()); // display the result on the displayer log.displayNL("The square of %d is %d", val, val*val); return true; }

Please use the same casing than for the function (first letter in lower case and after each word first letter in upper case) ie: myFunction, step, orderByName, lookAtThis

Author:
Vianney Lecroart

Nevrax France

Date:
2001

Definition at line 78 of file command.h.


Generated on Tue Mar 16 06:42:20 2004 for NeL by doxygen 1.3.6