ISIS Logo
UTILITIES
EPICS Utilities
Functions | Variables
iocstringtest.cpp File Reference

EPICS functions for testing strings against each other. More...

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <exception>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <map>
#include <list>
#include <string>
#include <time.h>
#include <sstream>
#include <fstream>
#include <vector>
#include <memory>
#include "epicsStdlib.h"
#include "epicsString.h"
#include "dbDefs.h"
#include "epicsMutex.h"
#include "dbBase.h"
#include "dbStaticLib.h"
#include "dbFldTypes.h"
#include "dbCommon.h"
#include "dbAccessDefs.h"
#include <epicsTypes.h>
#include <epicsTime.h>
#include <epicsThread.h>
#include <epicsTimer.h>
#include <iocsh.h>
#include "envDefs.h"
#include "macLib.h"
#include "errlog.h"
#include "postfix.h"
#include "cvtFast.h"
#include <boost/scoped_array.hpp>
#include <registryFunction.h>
#include <epicsExport.h>
#include "utilities.h"

Go to the source code of this file.

Functions

static int stringtestres (const char *lhs, int operation, const char *rhs)
 Does the actual calculation comparing the given strings to each other. More...
 
static void iocstringtest (const char *resultvar, const char *lhs, int operation, const char *rhs)
 Compares the given strings based on the operation flag and returns ' ' on true and '#' on false into the resultvar macro. More...
 
static void iocstringiftest (const char *resultvar, const char *lhs, int operation, const char *rhs)
 Compares the given strings based on the operation flag, putting the result in two different macros. More...
 
static void stringtestInitCallFunc (const iocshArgBuf *args)
 
static void stringiftestInitCallFunc (const iocshArgBuf *args)
 
static void iocstringtestRegister (void)
 
 epicsExportRegistrar (iocstringtestRegister)
 

Variables

static const iocshArg stringtestInitArg0 = { "resultvar", iocshArgString }
 The name of the macro to put the result of the calculation into. More...
 
static const iocshArg stringtestInitArg1 = { "lhs", iocshArgString }
 The left hand side argument. More...
 
static const iocshArg stringtestInitArg2 = { "operation", iocshArgInt }
 The operation to perform on the string. More...
 
static const iocshArg stringtestInitArg3 = { "rhs", iocshArgString }
 The right hand side argument. More...
 
static const iocshArg *const stringtestInitArgs [] = { &stringtestInitArg0, &stringtestInitArg1, &stringtestInitArg2, &stringtestInitArg3 }
 
static const iocshFuncDef stringtestInitFuncDef = {"stringtest", sizeof(stringtestInitArgs) / sizeof(iocshArg*), stringtestInitArgs}
 
static const iocshArg stringiftestInitArg0 = { "resultvar", iocshArgString }
 The name of the macro to put the result of the calculation into. More...
 
static const iocshArg stringiftestInitArg1 = { "lhs", iocshArgString }
 The left hand side argument. More...
 
static const iocshArg stringiftestInitArg2 = { "operation", iocshArgInt }
 The operation to perform on the string. More...
 
static const iocshArg stringiftestInitArg3 = { "rhs", iocshArgString }
 The right hand side argument. More...
 
static const iocshArg *const stringiftestInitArgs [] = { &stringiftestInitArg0, &stringiftestInitArg1, &stringiftestInitArg2, &stringiftestInitArg3 }
 
static const iocshFuncDef stringiftestInitFuncDef = {"stringiftest", sizeof(stringiftestInitArgs) / sizeof(iocshArg*), stringiftestInitArgs}
 

Detailed Description

EPICS functions for testing strings against each other.

Author
Freddie Akeroyd, STFC ISIS Facility fredd.nosp@m.ie.a.nosp@m.keroy.nosp@m.d@st.nosp@m.fc.ac.nosp@m..uk

Definition in file iocstringtest.cpp.

Function Documentation

epicsExportRegistrar ( iocstringtestRegister  )
static void iocstringiftest ( const char *  resultvar,
const char *  lhs,
int  operation,
const char *  rhs 
)
static

Compares the given strings based on the operation flag, putting the result in two different macros.

This function will create two macros called IFresultvar and IFNOTresultvar. If the comparison is true a '#' will be placed in IFNOTresultvar. If the comparison is false a '#' will be placed in IFresultvar.

E.g. to check if a macro named DO_I_EXIST does actually exist then do some follow up:

* stringtest("EXISTS", "$(DO_I_EXIST)")
* $(IFEXISTS) < st-existing.cmd
* $(IFNOTEXISTS) < st-not-existing.cmd
*

to check a macro named AM_I_CORRECT is equal to CORRECT_ANSWER then do some follow up:

* stringtest("EXPECTED", "$(AM_I_CORRECT)", 5, "CORRECT_ANSWER")
* $(IFEXPECTED) < st-expected.cmd
* $(IFNOTEXPECTED) < st-not-expected.cmd
*
Parameters
[in]resultvarThe name of the macro to put the result of the calculation into.
[in]lhsThe left hand side argument.
[in]operationThe operation to perform on the string. 0x1: verbose 0x2: strlen(lhs) > 0 (default) 0x4: lhs == rhs 0x8: reverse the above logic
[in]rhsThe right hand side argument.

Definition at line 171 of file iocstringtest.cpp.

References stringtestres().

Referenced by stringiftestInitCallFunc().

static void iocstringtest ( const char *  resultvar,
const char *  lhs,
int  operation,
const char *  rhs 
)
static

Compares the given strings based on the operation flag and returns ' ' on true and '#' on false into the resultvar macro.

E.g. to check if a macro named DO_I_EXIST does actually exist and put the result in a macro called EXISTS:

* stringtest("EXISTS", "$(DO_I_EXIST)")
*
Parameters
[in]resultvarThe name of the macro to put the result of the calculation into.
[in]lhsThe left hand side argument.
[in]operationThe operation to perform on the string. 0x1: verbose 0x2: strlen(lhs) > 0 (default) 0x4: lhs == rhs 0x8: reverse the above logic
[in]rhsThe right hand side argument.

Definition at line 126 of file iocstringtest.cpp.

References stringtestres().

Referenced by stringtestInitCallFunc().

static void iocstringtestRegister ( void  )
static

Definition at line 247 of file iocstringtest.cpp.

References stringiftestInitCallFunc(), and stringtestInitCallFunc().

static void stringiftestInitCallFunc ( const iocshArgBuf *  args)
static

Definition at line 242 of file iocstringtest.cpp.

References iocstringiftest().

Referenced by iocstringtestRegister().

static void stringtestInitCallFunc ( const iocshArgBuf *  args)
static

Definition at line 223 of file iocstringtest.cpp.

References iocstringtest().

Referenced by iocstringtestRegister().

static int stringtestres ( const char *  lhs,
int  operation,
const char *  rhs 
)
static

Does the actual calculation comparing the given strings to each other.

Helper function, not to be called from an IOC.

Definition at line 57 of file iocstringtest.cpp.

Referenced by iocstringiftest(), and iocstringtest().

Variable Documentation

const iocshArg stringiftestInitArg0 = { "resultvar", iocshArgString }
static

The name of the macro to put the result of the calculation into.

Definition at line 228 of file iocstringtest.cpp.

const iocshArg stringiftestInitArg1 = { "lhs", iocshArgString }
static

The left hand side argument.

Definition at line 229 of file iocstringtest.cpp.

const iocshArg stringiftestInitArg2 = { "operation", iocshArgInt }
static

The operation to perform on the string.

0x1: verbose 0x2: strlen(lhs) > 0 (default) 0x4: lhs == rhs 0x8: reverse the above logic

Definition at line 236 of file iocstringtest.cpp.

const iocshArg stringiftestInitArg3 = { "rhs", iocshArgString }
static

The right hand side argument.

Definition at line 237 of file iocstringtest.cpp.

const iocshArg* const stringiftestInitArgs[] = { &stringiftestInitArg0, &stringiftestInitArg1, &stringiftestInitArg2, &stringiftestInitArg3 }
static

Definition at line 238 of file iocstringtest.cpp.

const iocshFuncDef stringiftestInitFuncDef = {"stringiftest", sizeof(stringiftestInitArgs) / sizeof(iocshArg*), stringiftestInitArgs}
static

Definition at line 240 of file iocstringtest.cpp.

const iocshArg stringtestInitArg0 = { "resultvar", iocshArgString }
static

The name of the macro to put the result of the calculation into.

Definition at line 209 of file iocstringtest.cpp.

const iocshArg stringtestInitArg1 = { "lhs", iocshArgString }
static

The left hand side argument.

Definition at line 210 of file iocstringtest.cpp.

const iocshArg stringtestInitArg2 = { "operation", iocshArgInt }
static

The operation to perform on the string.

0x1: verbose 0x2: strlen(lhs) > 0 (default) 0x4: lhs == rhs 0x8: reverse the above logic

Definition at line 217 of file iocstringtest.cpp.

const iocshArg stringtestInitArg3 = { "rhs", iocshArgString }
static

The right hand side argument.

Definition at line 218 of file iocstringtest.cpp.

const iocshArg* const stringtestInitArgs[] = { &stringtestInitArg0, &stringtestInitArg1, &stringtestInitArg2, &stringtestInitArg3 }
static

Definition at line 219 of file iocstringtest.cpp.

const iocshFuncDef stringtestInitFuncDef = {"stringtest", sizeof(stringtestInitArgs) / sizeof(iocshArg*), stringtestInitArgs}
static

Definition at line 221 of file iocstringtest.cpp.

Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5