summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/archive.cpp5
-rw-r--r--src/archive.h12
-rw-r--r--src/list.h4
-rw-r--r--src/unit/archive.cpp50
4 files changed, 53 insertions, 18 deletions
diff --git a/src/archive.cpp b/src/archive.cpp
index accdeb1..90211fe 100644
--- a/src/archive.cpp
+++ b/src/archive.cpp
@@ -473,7 +473,8 @@ Bu::Archive &Bu::operator>>(Bu::Archive &ar, class Bu::Archival *p )
473 473
474Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) 474Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s )
475{ 475{
476 ar << (uint32_t)s.length(); 476 // This should be defined as long anyway, this is just insurance
477 ar << (long)s.length();
477 ar.write( s.c_str(), s.length() ); 478 ar.write( s.c_str(), s.length() );
478 479
479 return ar; 480 return ar;
@@ -481,7 +482,7 @@ Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s )
481 482
482Bu::Archive &Bu::operator>>( Bu::Archive &ar, std::string &s ) 483Bu::Archive &Bu::operator>>( Bu::Archive &ar, std::string &s )
483{ 484{
484 uint32_t l; 485 long l;
485 ar >> l; 486 ar >> l;
486 char *tmp = new char[l+1]; 487 char *tmp = new char[l+1];
487 tmp[l] = '\0'; 488 tmp[l] = '\0';
diff --git a/src/archive.h b/src/archive.h
index 95c8c0c..1d57724 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -256,10 +256,10 @@ namespace Bu
256 Archive &operator>>( Archive &ar, Hash<key,value> &h ) 256 Archive &operator>>( Archive &ar, Hash<key,value> &h )
257 { 257 {
258 h.clear(); 258 h.clear();
259 uint32_t nSize; 259 long nSize;
260 ar >> nSize; 260 ar >> nSize;
261 261
262 for( uint32_t j = 0; j < nSize; j++ ) 262 for( long j = 0; j < nSize; j++ )
263 { 263 {
264 key k; value v; 264 key k; value v;
265 ar >> k >> v; 265 ar >> k >> v;
@@ -285,10 +285,10 @@ namespace Bu
285 Archive &operator>>( Archive &ar, List<value> &h ) 285 Archive &operator>>( Archive &ar, List<value> &h )
286 { 286 {
287 h.clear(); 287 h.clear();
288 uint32_t nSize; 288 long nSize;
289 ar >> nSize; 289 ar >> nSize;
290 290
291 for( uint32_t j = 0; j < nSize; j++ ) 291 for( long j = 0; j < nSize; j++ )
292 { 292 {
293 value v; 293 value v;
294 ar >> v; 294 ar >> v;
@@ -314,10 +314,10 @@ namespace Bu
314 Archive &operator>>( Archive &ar, Set<value> &h ) 314 Archive &operator>>( Archive &ar, Set<value> &h )
315 { 315 {
316 h.clear(); 316 h.clear();
317 uint32_t nSize; 317 long nSize;
318 ar >> nSize; 318 ar >> nSize;
319 319
320 for( uint32_t j = 0; j < nSize; j++ ) 320 for( long j = 0; j < nSize; j++ )
321 { 321 {
322 value v; 322 value v;
323 ar >> v; 323 ar >> v;
diff --git a/src/list.h b/src/list.h
index ed28e15..2a40013 100644
--- a/src/list.h
+++ b/src/list.h
@@ -535,7 +535,7 @@ namespace Bu
535 * Get the current size of the list. 535 * Get the current size of the list.
536 *@returns (int) The current size of the list. 536 *@returns (int) The current size of the list.
537 */ 537 */
538 int getSize() const 538 long getSize() const
539 { 539 {
540 return nSize; 540 return nSize;
541 } 541 }
@@ -586,7 +586,7 @@ namespace Bu
586 Link *pLast; 586 Link *pLast;
587 linkalloc la; 587 linkalloc la;
588 valuealloc va; 588 valuealloc va;
589 int nSize; 589 long nSize;
590 cmpfunc cmp; 590 cmpfunc cmp;
591 }; 591 };
592} 592}
diff --git a/src/unit/archive.cpp b/src/unit/archive.cpp
index 531ece1..8e71f4b 100644
--- a/src/unit/archive.cpp
+++ b/src/unit/archive.cpp
@@ -15,6 +15,7 @@ public:
15 { 15 {
16 setName("Archive"); 16 setName("Archive");
17 addTest( Unit::testPrimitives ); 17 addTest( Unit::testPrimitives );
18 addTest( Unit::testContainers );
18 } 19 }
19 20
20 virtual ~Unit() 21 virtual ~Unit()
@@ -42,8 +43,8 @@ public:
42 ar << (unsigned int)14; 43 ar << (unsigned int)14;
43 ar << (long)15; 44 ar << (long)15;
44 ar << (unsigned long)16; 45 ar << (unsigned long)16;
45 //ar << (long long)17; 46 ar << (long long)17;
46 //ar << (unsigned long long)18; 47 ar << (unsigned long long)18;
47 ar.close(); 48 ar.close();
48 } 49 }
49 mb.setPos( 0 ); 50 mb.setPos( 0 );
@@ -65,8 +66,8 @@ public:
65 unsigned int p14; 66 unsigned int p14;
66 long p15; 67 long p15;
67 unsigned long p16; 68 unsigned long p16;
68 //long long p17; 69 long long p17;
69 //unsigned long long p18; 70 unsigned long long p18;
70 ar >> p1; 71 ar >> p1;
71 ar >> p2; 72 ar >> p2;
72 ar >> p3; 73 ar >> p3;
@@ -83,8 +84,8 @@ public:
83 ar >> p14; 84 ar >> p14;
84 ar >> p15; 85 ar >> p15;
85 ar >> p16; 86 ar >> p16;
86 //ar >> p17; 87 ar >> p17;
87 //ar >> p18; 88 ar >> p18;
88 unitTest( p1 == 1 ); 89 unitTest( p1 == 1 );
89 unitTest( p2 == 2 ); 90 unitTest( p2 == 2 );
90 unitTest( p3 == 3 ); 91 unitTest( p3 == 3 );
@@ -101,8 +102,41 @@ public:
101 unitTest( p14 == 14 ); 102 unitTest( p14 == 14 );
102 unitTest( p15 == 15 ); 103 unitTest( p15 == 15 );
103 unitTest( p16 == 16 ); 104 unitTest( p16 == 16 );
104 //unitTest( p17 == 17 ); 105 unitTest( p17 == 17 );
105 //unitTest( p18 == 18 ); 106 unitTest( p18 == 18 );
107 ar.close();
108 }
109 }
110
111 void testContainers()
112 {
113 Bu::MemBuf mb;
114 {
115 Bu::Archive ar( mb, Bu::Archive::save );
116 Bu::FString sStr("This is a test string.");
117 Bu::List<int> lList;
118 lList.append( 10 );
119 lList.append( 20 );
120 lList.append( 30 );
121 lList.append( 40 );
122 ar << sStr;
123 ar << lList;
124 ar.close();
125 }
126 mb.setPos( 0 );
127 {
128 Bu::Archive ar( mb, Bu::Archive::load );
129 Bu::FString sStr;
130 Bu::List<int> lList;
131 ar >> sStr;
132 ar >> lList;
133 unitTest( sStr == "This is a test string." );
134 unitTest( lList.getSize() == 4 );
135 Bu::List<int>::iterator i = lList.begin();
136 unitTest( *i == 10 ); i++;
137 unitTest( *i == 20 ); i++;
138 unitTest( *i == 30 ); i++;
139 unitTest( *i == 40 );
106 ar.close(); 140 ar.close();
107 } 141 }
108 } 142 }