Skip to content

Commit

Permalink
Back out r6976, r6977, r6980, r6981, which were namespace removals.
Browse files Browse the repository at this point in the history
There is nothing wrong with namespace, and these changes generated 1700 lines of
irrelevant diff output making it difficult to compare various revisions of CommonLibs.
  • Loading branch information
pat-thompson authored and iedemam committed Mar 31, 2014
1 parent c17e42b commit 0dc6d36
Show file tree
Hide file tree
Showing 18 changed files with 336 additions and 305 deletions.
8 changes: 5 additions & 3 deletions BitVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <sstream>
#include <string.h>

using namespace std;



BitVector::BitVector(const char *valString)
Expand Down Expand Up @@ -236,7 +238,7 @@ void BitVector::unmap(const unsigned *map, size_t mapSize, BitVector& dest) cons



std::ostream& operator<<(std::ostream& os, const BitVector& hv)
ostream& operator<<(ostream& os, const BitVector& hv)
{
for (size_t i=0; i<hv.size(); i++) {
if (hv.bit(i)) os << '1';
Expand Down Expand Up @@ -339,7 +341,7 @@ float SoftVector::getSNR() const
}


std::ostream& operator<<(std::ostream& os, const SoftVector& sv)
ostream& operator<<(ostream& os, const SoftVector& sv)
{
for (size_t i=0; i<sv.size(); i++) {
if (sv[i]<0.25) os << "0";
Expand Down Expand Up @@ -378,7 +380,7 @@ void BitVector::unpack(const unsigned char* src)
fillField(whole,src[bytes] >> (8-rem),rem);
}

void BitVector::hex(std::ostream& os) const
void BitVector::hex(ostream& os) const
{
os << std::hex;
unsigned digits = size()/4;
Expand Down
48 changes: 25 additions & 23 deletions BitVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <cstdlib>
#include <string.h>

using namespace std;

// We must have a gConfig now to include BitVector.
#include "Configuration.h"
ConfigurationTable gConfig;
Expand All @@ -40,49 +42,49 @@ ConfigurationTable gConfig;
void origTest()
{
BitVector v0("0000111100111100101011110000");
std::cout << v0 << std::endl;
cout << v0 << endl;
// (pat) The conversion from a string was inserting garbage into the result BitVector.
// Fixed now so only 0 or 1 are inserted, but lets check:
for (char *cp = v0.begin(); cp < v0.end(); cp++) std::cout << (int)*cp<<" ";
std::cout << std::endl;
for (char *cp = v0.begin(); cp < v0.end(); cp++) cout << (int)*cp<<" ";
cout << endl;

BitVector v1(v0);
v1.LSB8MSB();
std::cout <<v1 << " (byte swapped)" << std::endl;
cout <<v1 << " (byte swapped)" << endl;

// Test operator==
assert(v1 == v1);
std::cout <<"v0="<<v0 <<std::endl;
std::cout <<"v1="<<v1 <<std::endl;
cout <<"v0="<<v0 <<endl;
cout <<"v1="<<v1 <<endl;
assert(!(v0 == v1));

BitVector v5("000011110000");
int r1 = v5.peekField(0,8);
int r2 = v5.peekField(4,4);
int r3 = v5.peekField(4,8);
std::cout << r1 << ' ' << r2 << ' ' << r3 << std::endl;
std::cout << v5 << std::endl;
cout << r1 << ' ' << r2 << ' ' << r3 << endl;
cout << v5 << endl;
v5.fillField(0,0xa,4);
int r4 = v5.peekField(0,8);
std::cout << v5 << std::endl;
std::cout << r4 << std::endl;
cout << v5 << endl;
cout << r4 << endl;

v5.reverse8();
std::cout << v5 << std::endl;
cout << v5 << endl;

unsigned char ts[9] = "abcdefgh";
BitVector tp(70);
std::cout << "ts=" << ts << std::endl;
cout << "ts=" << ts << endl;
tp.unpack(ts);
std::cout << "tp=" << tp << std::endl;
cout << "tp=" << tp << endl;
tp.pack(ts);
std::cout << "ts=" << ts << std::endl;
cout << "ts=" << ts << endl;

BitVector v6("010101");
BitVector v7(3);
unsigned punk[3] = {1,2,5};
v6.copyPunctured(v7, punk, 3);
std::cout << "v7=" << v7 << std::endl;
cout << "v7=" << v7 << endl;
}


Expand All @@ -94,20 +96,20 @@ void foo(TestVector a)
}
void anotherTest()
{
std::cout << "START BitVector anotherTest" << std::endl;
cout << "START BitVector anotherTest" << endl;
TestVector v0("0000111100111100101011110000");
TestVector atest = v0.head(3);
std::cout << atest << std::endl;
std::cout << "Calling head" << std::endl;
std::cout << v0.head(3) << std::endl;
std::cout << "Passing BitVector" << std::endl;
cout << atest << endl;
cout << "Calling head" << endl;
cout << v0.head(3) << endl;
cout << "Passing BitVector" << endl;
// This calls Vector const copy constructor.
// That is because the implicitly declared copy constructor for BitVector is of the form (BitVector const&)
foo(v0);
const TestVector ctest("0000");
std::cout << ctest.cloneSegment(0,2) << std::endl;
std::cout << "after"<<std::endl;
std::cout << "FINISH anotherTest" << std::endl;
cout << ctest.cloneSegment(0,2) << endl;
cout << "after"<<endl;
cout << "FINISH anotherTest" << endl;
}

BitVector randomBitVector(int n)
Expand Down
Loading

0 comments on commit 0dc6d36

Please sign in to comment.