HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_VarScan.h File Reference
#include "UT_API.h"
+ Include dependency graph for UT_VarScan.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef const char *(* UTVarCallback )(const char *str, void *userdata)
 

Functions

UT_API int UTVariableScan (UT_WorkBuffer &outstr, const char *instr, UTVarCallback lookup, void *userdata, bool tildeexpand=true, bool commentsexpand=true, bool rawstringexpand=true)
 
UT_API int UTExprVariableScan (UT_WorkBuffer &outstr, const char *instr, UTVarCallback lookup, UTVarCallback expreval, void *userdata, bool varexpand=true, bool tildeexpand=true, bool commentsexpand=true, bool rawstringexpand=true)
 

Typedef Documentation

typedef const char*(* UTVarCallback)(const char *str, void *userdata)

Definition at line 20 of file UT_VarScan.h.

Function Documentation

UT_API int UTExprVariableScan ( UT_WorkBuffer outstr,
const char *  instr,
UTVarCallback  lookup,
UTVarCallback  expreval,
void userdata,
bool  varexpand = true,
bool  tildeexpand = true,
bool  commentsexpand = true,
bool  rawstringexpand = true 
)

UTExprVariableScan writes the output to a fixed length char * buffer in outstr of size n. The number of variables that were expanded is returned.

Note
If 0 is returned, outstr might still be different from instr due to backslash escaping.
UT_API int UTVariableScan ( UT_WorkBuffer outstr,
const char *  instr,
UTVarCallback  lookup,
void userdata,
bool  tildeexpand = true,
bool  commentsexpand = true,
bool  rawstringexpand = true 
)

UTVariableScan copies the input string instr to the work string outstr searching for variable references of the form $name or ${name} in the input string. Each such variable reference found in the input string is replaced by its value which is obtained by passing the variable name to the func- tion referenced by the given argument lookup. If the given function fails by returning a null pointer then the variable reference is replaced in the output string by a null string.

If a null function pointer is passed as the lookup argument, then UTVariableScan calls the function getenv to find the value of each variable.

UTVariableScan returns the integer number of variables which have been expanded.

Note
If 0 is returned, outstr might still be different from instr due to backslash escaping.

commentsexpand allows expanding inside C and C++ style comments. WARNING: It can currently be fooled by them showing up in strings!

rawstringexpand allows expanding inside r"" and r'' style raw strings.