CppUnit project page CppUnit home page

message.h

Go to the documentation of this file.
00001 #ifndef CPPUT_MESSAGE_H_INCLUDED
00002 # define CPPUT_MESSAGE_H_INCLUDED
00003 
00004 # include <cpput/forwards.h>
00005 # include <cpptl/conststring.h>
00006 # include <vector>
00007 
00008 
00009 namespace CppUT {
00010 
00014 class CPPUT_API Message
00015 {
00016 public:
00017    static Message none;
00018 
00019    Message();
00020 
00021    Message( const CppTL::StringBuffer &shortDescription );
00022 
00023    Message( const CppTL::StringConcatenator &shortDescription );
00024 
00025    Message( const CppTL::ConstString &shortDescription );
00026 
00027    Message( const std::string &shortDescription );
00028 
00029    Message( const char *shortDescription );
00030 
00031    bool empty() const;
00032 
00033    void insertAt( int index, 
00034                   const char *detail );
00035 
00036    void insertAt( int index, 
00037                   const std::string &detail );
00038 
00039    void insertAt( int index,
00040                   const Message &other );
00041 
00042    void add( const char *detail );   // needed to solve ambiguity due to implicit constructor
00043 
00044    void add( const std::string &detail );
00045 
00046    void add( const CppTL::ConstString &detail );
00047 
00048    void extend( const Message &other );
00049 
00050    int count() const;
00051 
00052    std::string at( int index ) const;
00053 
00054    std::string toString() const;
00055 
00056 private:
00057    typedef std::vector<CppTL::ConstString> Details;
00058    Details details_;
00059 };
00060 
00061 
00062 class CPPUT_API LazyMessage
00063 {
00064 public:
00065    static LazyMessage none;
00066 
00067    LazyMessage();
00068 
00069    LazyMessage( const CppTL::StringBuffer &shortDescription );
00070 
00071    LazyMessage( const CppTL::StringConcatenator &shortDescription );
00072 
00073    LazyMessage( const CppTL::ConstString &shortDescription );
00074 
00075    LazyMessage( const std::string &shortDescription );
00076 
00077    LazyMessage( const char *shortDescription );
00078 
00079    LazyMessage( const Message &message );
00080 
00081    Message makeMessage() const;
00082 
00083 private:
00084    union {
00085       const char *cz_;
00086       const std::string *stdString_;
00087       const CppTL::ConstString *constString_;
00088       const CppTL::StringConcatenator *concatenor_;
00089       const CppTL::StringBuffer *stringBuffer_;
00090       const Message *message_;
00091    } init_;
00092    enum Kind {
00093       defaultConstructor = 1,
00094       constChar,
00095       stdString,
00096       constString,
00097       concatenator,
00098       buffer,
00099       message
00100    };
00101    Kind kind_;
00102 };
00103 
00104 } // namespace CppUT
00105 
00106 
00107 #endif // CPPUT_MESSAGE_H_INCLUDED
00108 

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers