From: Ron F. <ro...@us...> - 2004-11-29 16:58:29
|
Update of /cvsroot/nsclspectcl/SpecTcl/Utility In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30096/Utility Modified Files: Tag: 5.1 DesignByContract.h Makefile.am NamedItem.h Refptr.h SpecMath.h Utility.WC Utility.omt buffer.h buftypes.h daqtypes.h histotypes.h Log Message: Begin port to 3.x compilers calling this 3.0 Index: DesignByContract.h =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/Utility/DesignByContract.h,v retrieving revision 4.1 retrieving revision 5.1 diff -C2 -d -r4.1 -r5.1 *** DesignByContract.h 6 Aug 2004 13:40:30 -0000 4.1 --- DesignByContract.h 29 Nov 2004 16:56:17 -0000 5.1 *************** *** 1,371 **** ! #ifndef __DESIGNBYCONTRACT_H__ ! #define __DESIGNBYCONTRACT_H__ ! ! #include <string> ! #include <stdexcept> ! #include <iostream> ! #include <sstream> ! ! ! namespace DesignByContract ! { ! ///////////////////////////// ! // General-purpose assertions ! ///////////////////////////// ! ! class DesignByContractException : public std::runtime_error ! { ! protected: ! // Construction - only for derived classes ! ! DesignByContractException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : std::runtime_error(what), ! file_(file), ! line_(line), ! errorPrefix_("DesignByContract failed") ! {} ! ! public: ! // Queries ! ! // Exception error prefix ! std::string errorPrefix() const { return errorPrefix_; } ! ! // Source file ! std::string file() const { return file_; } ! ! // Line number ! int line() const { return line_; } ! ! // Description (from base) ! // virtual const char *what() ! ! // Source, location and description of exception ! operator std::string() const ! { ! std::ostringstream stream; ! stream << "File: " << file() << "\nLine: " << line() << "\n" << errorPrefix() << ". " << what() << "\n"; ! return stream.str(); ! } ! ! protected: ! // Commands ! void setErrorPrefix(const std::string& errorPrefix) { errorPrefix_ = errorPrefix; } ! ! private: ! // Implementation ! ! std::string file_; ! int line_; ! std::string errorPrefix_; ! }; ! ! // Source, location and description of exception ! inline ! std::ostream& operator<<(std::ostream& stream, const DesignByContractException& e) ! { ! return stream << "File: " << e.file() << "\nLine: " << e.line() << "\n" << e.errorPrefix() << ". " << e.what() << "\n"; ! } ! ! class AssertionException : public DesignByContractException ! { ! public: ! AssertionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Assertion failed"); ! } ! }; ! ! typedef AssertionException Check; ! typedef AssertionException Assertion; ! ! /////////////////////////////////////////////// ! // Preconditions, Postconditions and Invariants ! /////////////////////////////////////////////// ! ! class PreconditionException : public DesignByContractException ! { ! public: ! PreconditionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Precondition failed"); ! } ! }; ! ! typedef PreconditionException Require; ! typedef PreconditionException Precondition; ! ! class PostconditionException : public DesignByContractException ! { ! public: ! PostconditionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Postcondition failed"); ! } ! }; ! ! typedef PostconditionException Ensure; ! typedef PostconditionException Postcondition; ! ! class InvariantException : public DesignByContractException ! { ! public: ! InvariantException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Invariant failed"); ! } ! }; ! ! typedef InvariantException Invariant; ! ! } // End namespace DesignByContract ! ! // Conditional Compilation Constants ! ! // DESIGN_BY_CONTRACT // Enable Design by Contract checks ! // USE_ASSERTIONS // Use ASSERT macros instead of exceptions ! // ! // These suggestions are based on Bertrand Meyer's Object-Oriented Software Construction (2nd Ed) p393 ! // http://www.eiffel.com/doc/manuals/technology/contract/ ! // ! // CHECK_ALL // Check assertions - implies checking preconditions, postconditions and invariants ! // CHECK_INVARIANT // Check invariants - implies checking preconditions and postconditions ! // CHECK_POSTCONDITION // Check postconditions - implies checking preconditions ! // CHECK_PRECONDITION // Check preconditions only, e.g., in Release build ! // ! // So to enable all checks and use exception handling then, in a header file, write: ! // ! // #define DESIGN_BY_CONTRACT ! // #define CHECK_ALL ! // ! // In your implementation file write: ! // ! // #include "mydefines.h" ! // #include "DesignByContract.h" ! // using namespace DesignByContract; ! // ! // Notes: ! // ! // In a derived class... ! // ! // 1. An overriding method may [only] weaken the precondition. ! // This means that the overriding precondition should be logically "or-ed" with the overridden precondition. ! // 2. An overriding method may [only] strengthen the postcondition. ! // This means that the overriding postcondition should be logically "and-ed" with the overridden postcondition. ! // 3. A derived class invariant should be logically "and-ed" with its base class invariant. ! ! #if (defined(DESIGN_BY_CONTRACT) && !defined(USE_ASSERTIONS)) ! ! #if defined(_DEBUG) ! ! #if defined(CHECK_ALL) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__) ! #define INVARIANT(assertion, what) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__, what) ! #define CHECK0(assertion) \ ! if (!(assertion)) throw Check(__FILE__, __LINE__) ! #define CHECK(assertion, what) \ ! if (!(assertion)) throw Check(__FILE__, __LINE__, what) ! ! #elif defined(CHECK_INVARIANT) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__) ! #define INVARIANT(assertion, what) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__, what) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_POSTCONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_PRECONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else // Disable everything ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // CHECK_ALL ! ! #else // Release ! ! // A suggested scheme is to enable preconditions only ! ! #if defined(CHECK_PRECONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif ! ! #endif // _DEBUG ! ! #elif (defined(DESIGN_BY_CONTRACT) && defined(USE_ASSERTIONS)) ! ! #if defined(_DEBUG) ! ! #if defined(CHECK_ALL) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT(assertion, what) _ASSERTE(("Invariant failed." what, assertion)) ! #define INVARIANT0(assertion) _ASSERTE(("Invariant failed.", assertion)) ! #define CHECK(assertion, what) _ASSERTE(("Assertion failed." what, assertion)) ! #define CHECK0(assertion) _ASSERTE(("Assertion failed.", assertion)) ! ! #elif defined(CHECK_INVARIANT) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT(assertion, what) _ASSERTE(("Invariant failed." what, assertion)) ! #define INVARIANT0(assertion) _ASSERTE(("Invariant failed.", assertion)) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_POSTCONDITION) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_PRECONDITION) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else // Disable everything ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // CHECK_ALL ! ! #else // Release - no assertions possible ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // _DEBUG ! ! #else // Not DESIGN_BY_CONTRACT - disable everything ! ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! ! #endif // DESIGN_BY_CONTRACT ! ! #endif //__DESIGNBYCONTRACT_H__ --- 1,371 ---- ! #ifndef __DESIGNBYCONTRACT_H__ ! #define __DESIGNBYCONTRACT_H__ ! ! #include <string> ! #include <stdexcept> ! #include <iostream> ! #include <sstream> ! ! ! namespace DesignByContract ! { ! ///////////////////////////// ! // General-purpose assertions ! ///////////////////////////// ! ! class DesignByContractException : public std::runtime_error ! { ! protected: ! // Construction - only for derived classes ! ! DesignByContractException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : std::runtime_error(what), ! file_(file), ! line_(line), ! errorPrefix_("DesignByContract failed") ! {} ! ! public: ! // Queries ! ! // Exception error prefix ! std::string errorPrefix() const { return errorPrefix_; } ! ! // Source file ! std::string file() const { return file_; } ! ! // Line number ! int line() const { return line_; } ! ! // Description (from base) ! // virtual const char *what() ! ! // Source, location and description of exception ! operator std::string() const ! { ! std::ostringstream stream; ! stream << "File: " << file() << "\nLine: " << line() << "\n" << errorPrefix() << ". " << what() << "\n"; ! return stream.str(); ! } ! ! protected: ! // Commands ! void setErrorPrefix(const std::string& errorPrefix) { errorPrefix_ = errorPrefix; } ! ! private: ! // Implementation ! ! std::string file_; ! int line_; ! std::string errorPrefix_; ! }; ! ! // Source, location and description of exception ! inline ! std::ostream& operator<<(std::ostream& stream, const DesignByContractException& e) ! { ! return stream << "File: " << e.file() << "\nLine: " << e.line() << "\n" << e.errorPrefix() << ". " << e.what() << "\n"; ! } ! ! class AssertionException : public DesignByContractException ! { ! public: ! AssertionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Assertion failed"); ! } ! }; ! ! typedef AssertionException Check; ! typedef AssertionException Assertion; ! ! /////////////////////////////////////////////// ! // Preconditions, Postconditions and Invariants ! /////////////////////////////////////////////// ! ! class PreconditionException : public DesignByContractException ! { ! public: ! PreconditionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Precondition failed"); ! } ! }; ! ! typedef PreconditionException Require; ! typedef PreconditionException Precondition; ! ! class PostconditionException : public DesignByContractException ! { ! public: ! PostconditionException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Postcondition failed"); ! } ! }; ! ! typedef PostconditionException Ensure; ! typedef PostconditionException Postcondition; ! ! class InvariantException : public DesignByContractException ! { ! public: ! InvariantException(const std::string& file, ! int line, ! const std::string& what = std::string()) ! : DesignByContractException(file, line, what) ! { ! setErrorPrefix("Invariant failed"); ! } ! }; ! ! typedef InvariantException Invariant; ! ! } // End namespace DesignByContract ! ! // Conditional Compilation Constants ! ! // DESIGN_BY_CONTRACT // Enable Design by Contract checks ! // USE_ASSERTIONS // Use ASSERT macros instead of exceptions ! // ! // These suggestions are based on Bertrand Meyer's Object-Oriented Software Construction (2nd Ed) p393 ! // http://www.eiffel.com/doc/manuals/technology/contract/ ! // ! // CHECK_ALL // Check assertions - implies checking preconditions, postconditions and invariants ! // CHECK_INVARIANT // Check invariants - implies checking preconditions and postconditions ! // CHECK_POSTCONDITION // Check postconditions - implies checking preconditions ! // CHECK_PRECONDITION // Check preconditions only, e.g., in Release build ! // ! // So to enable all checks and use exception handling then, in a header file, write: ! // ! // #define DESIGN_BY_CONTRACT ! // #define CHECK_ALL ! // ! // In your implementation file write: ! // ! // #include "mydefines.h" ! // #include "DesignByContract.h" ! // using namespace DesignByContract; ! // ! // Notes: ! // ! // In a derived class... ! // ! // 1. An overriding method may [only] weaken the precondition. ! // This means that the overriding precondition should be logically "or-ed" with the overridden precondition. ! // 2. An overriding method may [only] strengthen the postcondition. ! // This means that the overriding postcondition should be logically "and-ed" with the overridden postcondition. ! // 3. A derived class invariant should be logically "and-ed" with its base class invariant. ! ! #if (defined(DESIGN_BY_CONTRACT) && !defined(USE_ASSERTIONS)) ! ! #if defined(_DEBUG) ! ! #if defined(CHECK_ALL) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__) ! #define INVARIANT(assertion, what) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__, what) ! #define CHECK0(assertion) \ ! if (!(assertion)) throw Check(__FILE__, __LINE__) ! #define CHECK(assertion, what) \ ! if (!(assertion)) throw Check(__FILE__, __LINE__, what) ! ! #elif defined(CHECK_INVARIANT) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__) ! #define INVARIANT(assertion, what) \ ! if (!(assertion)) throw Invariant(__FILE__, __LINE__, what) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_POSTCONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__) ! #define ENSURE(assertion, what) \ ! if (!(assertion)) throw Ensure(__FILE__, __LINE__, what) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_PRECONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else // Disable everything ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // CHECK_ALL ! ! #else // Release ! ! // A suggested scheme is to enable preconditions only ! ! #if defined(CHECK_PRECONDITION) ! ! #define REQUIRE0(assertion) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__) ! #define REQUIRE(assertion, what) \ ! if (!(assertion)) throw Require(__FILE__, __LINE__, what) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif ! ! #endif // _DEBUG ! ! #elif (defined(DESIGN_BY_CONTRACT) && defined(USE_ASSERTIONS)) ! ! #if defined(_DEBUG) ! ! #if defined(CHECK_ALL) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT(assertion, what) _ASSERTE(("Invariant failed." what, assertion)) ! #define INVARIANT0(assertion) _ASSERTE(("Invariant failed.", assertion)) ! #define CHECK(assertion, what) _ASSERTE(("Assertion failed." what, assertion)) ! #define CHECK0(assertion) _ASSERTE(("Assertion failed.", assertion)) ! ! #elif defined(CHECK_INVARIANT) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT(assertion, what) _ASSERTE(("Invariant failed." what, assertion)) ! #define INVARIANT0(assertion) _ASSERTE(("Invariant failed.", assertion)) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_POSTCONDITION) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE(assertion, what) _ASSERTE(("Postcondition failed." what, assertion)) ! #define ENSURE0(assertion) _ASSERTE(("Postcondition failed.", assertion)) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #elif defined(CHECK_PRECONDITION) ! ! #define REQUIRE(assertion, what) _ASSERTE(("Precondition failed." what, assertion)) ! #define REQUIRE0(assertion) _ASSERTE(("Precondition failed.", assertion)) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #else // Disable everything ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // CHECK_ALL ! ! #else // Release - no assertions possible ! ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! ! #endif // _DEBUG ! ! #else // Not DESIGN_BY_CONTRACT - disable everything ! ! #define CHECK0(assertion) ((void)0) ! #define CHECK(assertion, what) ((void)0) ! #define REQUIRE0(assertion) ((void)0) ! #define REQUIRE(assertion, what) ((void)0) ! #define ENSURE0(assertion) ((void)0) ! #define ENSURE(assertion, what) ((void)0) ! #define INVARIANT0(assertion) ((void)0) ! #define INVARIANT(assertion, what) ((void)0) ! ! #endif // DESIGN_BY_CONTRACT ! ! #endif //__DESIGNBYCONTRACT_H__ Index: NamedItem.h =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/Utility/NamedItem.h,v retrieving revision 4.3 retrieving revision 5.1 diff -C2 -d -r4.3 -r5.1 *** NamedItem.h 25 Aug 2003 16:11:56 -0000 4.3 --- NamedItem.h 29 Nov 2004 16:56:17 -0000 5.1 *************** *** 294,297 **** --- 294,304 ---- Change Log: $Log$ + Revision 5.1 2004/11/29 16:56:17 ron-fox + Begin port to 3.x compilers calling this 3.0 + + Revision 4.3.4.1 2004/09/24 11:44:00 ron-fox + Trust STL String constructors to do the right thing.. what we were doing + was giving Rational/Purify some fits. + Revision 4.3 2003/08/25 16:11:56 ron-fox Merge with kanayo's code *************** *** 299,302 **** --- 306,316 ---- Revision 4.2 2003/03/25 12:03:17 ron-fox Added Change log comment generated from the CVS $Log$ + Added Change log comment generated from the CVS Revision 5.1 2004/11/29 16:56:17 ron-fox + Added Change log comment generated from the CVS Begin port to 3.x compilers calling this 3.0 + Added Change log comment generated from the CVS + Added Change log comment generated from the CVS Revision 4.3.4.1 2004/09/24 11:44:00 ron-fox + Added Change log comment generated from the CVS Trust STL String constructors to do the right thing.. what we were doing + Added Change log comment generated from the CVS was giving Rational/Purify some fits. + Added Change log comment generated from the CVS Added Change log comment generated from the CVS Revision 4.3 2003/08/25 16:11:56 ron-fox Added Change log comment generated from the CVS Merge with kanayo's code *************** *** 331,337 **** {} CNamedItem ( std::string am_sName, UInt_t am_nNumber ) ! : m_nNumber (am_nNumber) { // Some STL string imps ! m_sName.resize(strlen(am_sName.c_str()) + 2, 0); // Butcher construction. ! m_sName = am_sName; } --- 345,352 ---- {} CNamedItem ( std::string am_sName, UInt_t am_nNumber ) ! : ! m_sName(am_sName), ! m_nNumber (am_nNumber) { ! } Index: histotypes.h =================================================================== RCS file: /cvsroot/nsclspectcl/SpecTcl/Utility/histotypes.h,v retrieving revision 4.5 retrieving revision 5.1 diff -C2 -d -r4.5 -r5.1 *** histotypes.h 25 Aug 2003 16:25:33 -0000 4.5 --- histotypes.h 29 Nov 2004 16:56:17 -0000 5.1 *************** *** 294,297 **** --- 294,300 ---- Change log: $Log$ + Revision 5.1 2004/11/29 16:56:17 ron-fox + Begin port to 3.x compilers calling this 3.0 + Revision 4.5 2003/08/25 16:25:33 ron-fox Initial starting point for merge with filtering -- this probably does not |