A fuzzy logic C++ library
Defines
private.hpp File Reference

private header, symbols here never get exported in user space, only included in .cpp files More...

+ This graph shows which files directly or indirectly include this file:

Defines

#define STR_EXPAND(tok)   #tok
#define STR(tok)   STR_EXPAND(tok)
#define BUF_SIZE   512
 Size of temporary buffer for file/string operations.
#define FLOAT_ARE_EQUAL(a, b)   ( fabs( (a)-(b) ) <= SLIFIS_EPSILON_REAL * std::max( fabs(a), fabs(b) ) )
 A macro for comparing floating point values.
#define SLIFIS_XML_READ_STRING_ATTRIB(a, b)
#define SLIFIS_XML_READ_INT_ATTRIB(a, b)
#define SLIFIS_XML_READ_INT_ATTRIB_2(a, t, b)
#define SLIFIS_XML_READ_DOUBLE_ATTRIB(a, b)
#define STREAM_OK_TEST(f)
 Macro for I/O operations. Checks that stream f is still ok, triggers an error if not.
#define STREAMCHECK_INIT(f)
 Macro for I/O operations. Must be placed at the beginning of each function that does some I/O.
#define STREAM_WRITE_STRING(f, s1)
 Macro for writing a string s to a binary stream (ofstream) f.
#define STREAM_READ_STRING(f, s)
 Macro for reading a std::string s from a binary file f. Third argument n (int) is there only for debugging purposes.
#define SWITCH_ERROR
 This macro is used in switch statements on enums to indicate the default case that should never be triggered.
#define VECTOR_ELEM(a, b)   a[b]

Detailed Description

private header, symbols here never get exported in user space, only included in .cpp files


Define Documentation

#define STR_EXPAND (   tok)    #tok
#define STR (   tok)    STR_EXPAND(tok)
#define BUF_SIZE   512

Size of temporary buffer for file/string operations.

#define FLOAT_ARE_EQUAL (   a,
 
)    ( fabs( (a)-(b) ) <= SLIFIS_EPSILON_REAL * std::max( fabs(a), fabs(b) ) )

A macro for comparing floating point values.

For best performance, don't put any function calls as arguments, as they will be called several times...

Referenced by slifis::MEMBFUNC::Fuzzify(), slifis::FPOINT::operator==(), slifis::ROOT_RULE::operator==(), slifis::MEMBFUNC::P_PointIsTooClose(), and slifis::PrintDifferences().

#define SLIFIS_XML_READ_STRING_ATTRIB (   a,
 
)
Value:
std::string b; \
        if( TIXML_SUCCESS != pElem->QueryStringAttribute( (a), &b ) ) \
        { \
                SLIFIS_ERROR_LOG << "xml error: unable to read 'std::string' attribute \"" << (a) << "\"\n"; \
                return false; \
        }

Referenced by slifis::FUZZY_ROOT::P_Read_XML(), slifis::RULE_IDX::P_Read_XML(), and slifis::MEMBFUNC::P_Read_XML().

#define SLIFIS_XML_READ_INT_ATTRIB (   a,
 
)
Value:
int b; \
        if( TIXML_SUCCESS != pElem->QueryIntAttribute( (a), &b ) ) \
        { \
                SLIFIS_ERROR_LOG << "xml error: unable to read 'int' attribute \"" << (a) << "\"\n"; \
                return false; \
        }

Referenced by slifis::FUZZY_ROOT::P_Read_XML(), slifis::RULE_BASE::P_Read_XML(), slifis::RULE_IDX::P_Read_XML(), slifis::MEMBFUNC::P_Read_XML(), and slifis::SLIFIS::P_Read_XML().

#define SLIFIS_XML_READ_INT_ATTRIB_2 (   a,
  t,
 
)
Value:
{ \
                int c; \
                if( TIXML_SUCCESS != pElem->QueryIntAttribute( (a), &c ) ) \
                { \
                        SLIFIS_ERROR_LOG << "xml error: unable to read 'int' attribute \"" << (a) << "\"\n"; \
                        return false; \
                } \
                b = (t)c; \
        }

Referenced by slifis::SLIFIS::P_Read_XML().

#define SLIFIS_XML_READ_DOUBLE_ATTRIB (   a,
 
)
Value:
double b; \
        if( TIXML_SUCCESS != pElem->QueryDoubleAttribute( (a), &b ) ) \
        { \
                SLIFIS_ERROR_LOG << "xml error: unable to read 'double' attribute \"" << (a) << "\"\n"; \
                return false; \
        }

Referenced by slifis::FPOINT::P_Read_XML(), and slifis::RULE_IDX::P_Read_XML().

#define STREAM_OK_TEST (   f)
Value:
stream_test_counter++; \
                if( f.good() == false ) \
                { \
                        SLIFIS_ERROR_LOG << "File error at step " << __COUNTER__ << ", counter="<< stream_test_counter <<", in "<< SLIFIS_FUNCTION << endl; \
                        __OUT__; \
                        return false; \
                } \

Macro for I/O operations. Checks that stream f is still ok, triggers an error if not.

Referenced by slifis::FPOINT::P_Read_bin(), slifis::ROOT_RULE::P_Read_bin(), slifis::FUZZY_ROOT::P_Read_bin(), slifis::RULE_BASE::P_Read_bin(), slifis::RULE_IDX::P_Read_bin(), slifis::MEMBFUNC::P_Read_bin(), slifis::SLIFIS::P_Read_bin(), slifis::FPOINT::P_Write_bin(), slifis::INF_PARAMS::P_Write_bin(), slifis::ROOT_RULE::P_Write_bin(), slifis::FUZZY_ROOT::P_Write_bin(), slifis::RULE_BASE::P_Write_bin(), slifis::RULE_IDX::P_Write_bin(), slifis::MEMBFUNC::P_Write_bin(), and slifis::SLIFIS::P_Write_bin().

#define STREAMCHECK_INIT (   f)
#define STREAM_WRITE_STRING (   f,
  s1 
)
Value:
{ \
                std::string s(s1); \
                size_t size = s.size(); \
                f.write( (char*)&size, sizeof( size_t ) ); \
                STREAM_OK_TEST( f ); \
                const char* p = s.c_str(); \
                f.write( (char*)p, size ); \
                STREAM_OK_TEST( f ); \
        }

Macro for writing a string s to a binary stream (ofstream) f.

the s1 argument if first copied into a string, so we can use this macro with a std::string or with a const char*

Referenced by slifis::FUZZY_ROOT::P_Write_bin(), slifis::MEMBFUNC::P_Write_bin(), and slifis::SLIFIS::P_Write_bin().

#define STREAM_READ_STRING (   f,
 
)
Value:
{ \
                size_t size; \
                f.read( (char*)&size, sizeof( size_t ) ); \
                STREAM_OK_TEST( f ); \
                char* p = new char [size+1]; \
                f.read( p, size ); \
                STREAM_OK_TEST( f ); \
                p[size]=0; \
                s = p; \
                delete[] p; \
        }

Macro for reading a std::string s from a binary file f. Third argument n (int) is there only for debugging purposes.

This does the following:

  • read in ifstream the size of the string
  • allocate a buffer for it
  • read the string
  • add the null character
  • copy the buffer in output string
  • release buffer

Referenced by slifis::FUZZY_ROOT::P_Read_bin(), slifis::MEMBFUNC::P_Read_bin(), and slifis::SLIFIS::P_Read_bin().

#define SWITCH_ERROR
#define VECTOR_ELEM (   a,
 
)    a[b]