certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi libCERTI/MessageBuffer.hh test/utility/Ce... [br_DEV_H


From: certi-cvs
Subject: [certi-cvs] certi libCERTI/MessageBuffer.hh test/utility/Ce... [br_DEV_HETEROGENEOUS]
Date: Tue, 08 Apr 2008 10:44:21 +0000

CVSROOT:        /sources/certi
Module name:    certi
Branch:         br_DEV_HETEROGENEOUS
Changes by:     Eric NOULARD <erk>      08/04/08 10:44:21

Modified files:
        libCERTI       : MessageBuffer.hh 
        test/utility   : CertiUtilTests.cc 

Log message:
        Add write/read_bool API.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/MessageBuffer.hh?cvsroot=certi&only_with_tag=br_DEV_HETEROGENEOUS&r1=3.6&r2=3.6.2.1
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/CertiUtilTests.cc?cvsroot=certi&only_with_tag=br_DEV_HETEROGENEOUS&r1=1.8&r2=1.8.2.1

Patches:
Index: libCERTI/MessageBuffer.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/MessageBuffer.hh,v
retrieving revision 3.6
retrieving revision 3.6.2.1
diff -u -b -r3.6 -r3.6.2.1
--- libCERTI/MessageBuffer.hh   3 Mar 2008 15:15:09 -0000       3.6
+++ libCERTI/MessageBuffer.hh   8 Apr 2008 10:44:21 -0000       3.6.2.1
@@ -249,6 +249,20 @@
        std::string
        read_string();
 
+       int32_t
+       write_bool(const bool toggle) {
+               if(toggle) {
+                       write_uint8(1);
+               } else {
+                       write_uint8(0);
+               }
+       };
+       
+       bool
+       read_bool() {   
+               return (1==read_uint8());
+       };
+
        MessageBuffer& operator<<(const uint8_t data) {
                this->write_uint8(data);
                return *this;

Index: test/utility/CertiUtilTests.cc
===================================================================
RCS file: /sources/certi/certi/test/utility/CertiUtilTests.cc,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -b -r1.8 -r1.8.2.1
--- test/utility/CertiUtilTests.cc      3 Mar 2008 15:15:09 -0000       1.8
+++ test/utility/CertiUtilTests.cc      8 Apr 2008 10:44:21 -0000       1.8.2.1
@@ -64,6 +64,8 @@
        int64_t  i64  = -1000000000;
        float    f32  = 3.1415927;
        double   d64  = 2.7182818;
+       bool     trueBool  = true;
+       bool     falseBool = false;
        char*    vstr = NULL;
        std::string  vstdstr;
        uint8_t  vu8   = 0;
@@ -76,6 +78,8 @@
        int64_t  vi64  = 0;
        float    vf32  = 0.0;
        double   vd64  = 0.0;   
+       bool     vtrueBool  = false;
+       bool     vfalseBool = true;             
        cout << "Testing MessageBuffer class BEGIN..."<<endl;
        cout << "    Current (Default) MessageBuffer MaxSize               = 
"<< MsgBuf.maxSize() <<endl;
        cout << "    Current (initially void) MessageBuffer size = "<< 
MsgBuf.size()<<endl;
@@ -93,6 +97,8 @@
        MsgBuf.write_int64(i64);
        MsgBuf.write_float(f32);
        MsgBuf.write_double(d64);
+       MsgBuf.write_bool(trueBool);
+       MsgBuf.write_bool(falseBool);
        cout << "    std::string = " << stdstr << endl;
        MsgBuf.write_string(stdstr);
        cout << "    Current MessageBuffer size                  = "<< 
MsgBuf.size()<<endl;
@@ -112,6 +118,8 @@
        MsgBuf.read_int64(&vi64); assert(vi64==i64);
        MsgBuf.read_float(&vf32); assert(vf32==f32);
        MsgBuf.read_double(&vd64); assert(vd64==d64);   
+       vtrueBool = MsgBuf.read_bool(); assert(trueBool==vtrueBool);
+       vfalseBool = MsgBuf.read_bool(); assert(falseBool==vfalseBool);
        vstdstr  = MsgBuf.read_string(); assert(vstdstr==stdstr);
        cout << "    std::string = " << vstdstr << endl;
        cout << "    All encoded/decoded values are equal." << endl;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]