Skip to content

Commit

Permalink
Various consistency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kspangsege committed Mar 21, 2013
1 parent f6ee2af commit 4452403
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 50 deletions.
46 changes: 23 additions & 23 deletions src/tightdb/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void Array::Preset(size_t bitwidth, size_t count)

void Array::Preset(int64_t min, int64_t max, size_t count)
{
size_t w = std::max(BitWidth(max), BitWidth(min));
size_t w = ::max(BitWidth(max), BitWidth(min));
Preset(w, count);
}

Expand Down Expand Up @@ -1531,7 +1531,7 @@ template <size_t w> void Array::sort()

size_t lo = 0;
size_t hi = m_len - 1;
std::vector<size_t> count;
vector<size_t> count;
int64_t min;
int64_t max;
bool b = false;
Expand Down Expand Up @@ -1669,9 +1669,9 @@ template<size_t w> void Array::QuickSort(size_t lo, size_t hi)
if (i < (int)hi) QuickSort(i, hi);
}

std::vector<int64_t> Array::ToVector() const
vector<int64_t> Array::ToVector() const
{
std::vector<int64_t> v;
vector<int64_t> v;
const size_t count = size();
for (size_t t = 0; t < count; ++t)
v.push_back(Get(t));
Expand All @@ -1694,12 +1694,12 @@ bool Array::Compare(const Array& c) const

void Array::Print() const
{
std::cout << std::hex << GetRef() << std::dec << ": (" << size() << ") ";
cout << hex << GetRef() << dec << ": (" << size() << ") ";
for (size_t i = 0; i < size(); ++i) {
if (i) std::cout << ", ";
std::cout << Get(i);
if (i) cout << ", ";
cout << Get(i);
}
std::cout << "\n";
cout << "\n";
}

void Array::Verify() const
Expand All @@ -1714,25 +1714,25 @@ void Array::Verify() const
TIGHTDB_ASSERT(ref_in_parent == (IsValid() ? m_ref : 0));
}

void Array::ToDot(std::ostream& out, const char* title) const
void Array::ToDot(ostream& out, StringData title) const
{
const size_t ref = GetRef();

if (title) {
out << "subgraph cluster_" << ref << " {" << std::endl;
out << " label = \"" << title << "\";" << std::endl;
out << " color = white;" << std::endl;
if (0 < title.size()) {
out << "subgraph cluster_" << ref << " {" << endl;
out << " label = \"" << title << "\";" << endl;
out << " color = white;" << endl;
}

out << "n" << std::hex << ref << std::dec << "[shape=none,label=<";
out << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\"><TR>" << std::endl;
out << "n" << hex << ref << dec << "[shape=none,label=<";
out << "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\"><TR>" << endl;

// Header
out << "<TD BGCOLOR=\"lightgrey\"><FONT POINT-SIZE=\"7\"> ";
out << "0x" << std::hex << ref << std::dec << "<BR/>";
out << "0x" << hex << ref << dec << "<BR/>";
if (m_isNode) out << "IsNode<BR/>";
if (m_hasRefs) out << "HasRefs<BR/>";
out << "</FONT></TD>" << std::endl;
out << "</FONT></TD>" << endl;

// Values
for (size_t i = 0; i < m_len; ++i) {
Expand All @@ -1744,23 +1744,23 @@ void Array::ToDot(std::ostream& out, const char* title) const
else out << "<TD PORT=\"" << i << "\">";
}
else out << "<TD>" << v;
out << "</TD>" << std::endl;
out << "</TD>" << endl;
}

out << "</TR></TABLE>>];" << std::endl;
if (title) out << "}" << std::endl;
out << "</TR></TABLE>>];" << endl;
if (0 < title.size()) out << "}" << endl;

if (m_hasRefs) {
for (size_t i = 0; i < m_len; ++i) {
const int64_t target = Get(i);
if (target == 0 || target & 0x1) continue; // zero-refs and refs that are not 64-aligned do not point to sub-trees

out << "n" << std::hex << ref << std::dec << ":" << i;
out << " -> n" << std::hex << target << std::dec << std::endl;
out << "n" << hex << ref << dec << ":" << i;
out << " -> n" << hex << target << dec << endl;
}
}

out << std::endl;
out << endl;
}

void Array::Stats(MemStats& stats) const
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class Array: public ArrayParent {
#ifdef TIGHTDB_DEBUG
void Print() const;
void Verify() const;
void ToDot(std::ostream& out, const char* title=NULL) const;
void ToDot(std::ostream& out, StringData title = StringData()) const;
void Stats(MemStats& stats) const;
#endif // TIGHTDB_DEBUG

Expand Down
6 changes: 3 additions & 3 deletions src/tightdb/array_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void ArrayBinary::ToDot(ostream& out, const char* title) const
if (title) out << "\\n'" << title << "'";
out << "\";" << endl;

Array::ToDot(out, "binary_top");
m_offsets.ToDot(out, "offsets");
m_blob.ToDot(out, "blob");
// Array::ToDot(out, "binary_top");
// m_offsets.ToDot(out, "offsets");
// m_blob.ToDot(out, "blob");

out << "}" << endl;
}
Expand Down
6 changes: 3 additions & 3 deletions src/tightdb/array_string_long.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ void ArrayStringLong::ToDot(ostream& out, const char* title) const
if (title) out << "\\n'" << title << "'";
out << "\";" << endl;

Array::ToDot(out, "stringlong_top");
m_offsets.ToDot(out, "offsets");
m_blob.ToDot(out, "blob");
// Array::ToDot(out, "stringlong_top");
// m_offsets.ToDot(out, "offsets");
// m_blob.ToDot(out, "blob");

out << "}" << endl;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,11 @@ void ColumnBase::ArrayToDot(std::ostream& out, const Array& array) const
out << " label = \"Node\";" << std::endl;

array.ToDot(out);
offsets.ToDot(out, "offsets");
// offsets.ToDot(out, "offsets");

out << "}" << std::endl;

refs.ToDot(out, "refs");
// refs.ToDot(out, "refs");

const size_t count = refs.size();
for (size_t i = 0; i < count; ++i) {
Expand Down
8 changes: 4 additions & 4 deletions src/tightdb/column_mixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void ColumnMixed::ToDot(std::ostream& out, StringData title) const
if (0 < title.size()) out << "\\n'" << title << "'";
out << "\";" << std::endl;

m_array->ToDot(out, "mixed_top");
// m_array->ToDot(out, "mixed_top");

// Write sub-tables
const size_t count = Size();
Expand All @@ -335,11 +335,11 @@ void ColumnMixed::ToDot(std::ostream& out, StringData title) const
subtable->to_dot(out);
}

m_types->ToDot(out, "types");
m_refs->ToDot(out, "refs");
// m_types->ToDot(out, "types");
// m_refs->ToDot(out, "refs");

if (m_array->size() > 2) {
m_data->ToDot(out, "data");
// m_data->ToDot(out, "data");
}

out << "}" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/column_string_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ void ColumnStringEnum::ToDot(std::ostream& out, StringData title) const
if (0 < title.size()) out << "\\n'" << title << "'";
out << "\";" << std::endl;

m_keys.ToDot(out, "keys");
Column::ToDot(out, "values");
// m_keys.ToDot(out, "keys");
// Column::ToDot(out, "values");

out << "}" << std::endl;
}
Expand Down
6 changes: 3 additions & 3 deletions src/tightdb/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ void Group::to_dot(std::ostream& out) const
out << "subgraph cluster_group {" << endl;
out << " label = \"Group\";" << endl;

m_top.ToDot(out, "group_top");
m_tableNames.ToDot(out, "table_names");
m_tables.ToDot(out, "tables");
// m_top.ToDot(out, "group_top");
// m_tableNames.ToDot(out, "table_names");
// m_tables.ToDot(out, "tables");

// Tables
for (size_t i = 0; i < m_tables.size(); ++i) {
Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/index_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,11 @@ void StringIndex::ArrayToDot(std::ostream& out, const Array& array) const
}

array.ToDot(out);
KeysToDot(out, offsets, "keys");
// KeysToDot(out, offsets, "keys");

out << "}" << std::endl;

refs.ToDot(out, "refs");
// refs.ToDot(out, "refs");

const size_t count = refs.size();
for (size_t i = 0; i < count; ++i) {
Expand Down
10 changes: 8 additions & 2 deletions src/tightdb/mixed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ class Mixed {

// These are shortcuts for Mixed(StringData(c_str)), and are
// needed to avoid unwanted implicit conversion of char* to bool.
Mixed( char* c_str) TIGHTDB_NOEXCEPT { set_string(c_str); }
Mixed(const char* c_str) TIGHTDB_NOEXCEPT { set_string(c_str); }
// Mixed( char* c_str) TIGHTDB_NOEXCEPT { set_string(c_str); }
// Mixed(const char* c_str) TIGHTDB_NOEXCEPT { set_string(c_str); }

template<class T> Mixed(T*) { typename T::viggo x; }

struct subtable_tag {};
Mixed(subtable_tag) TIGHTDB_NOEXCEPT: m_type(type_Table) {}
Expand Down Expand Up @@ -189,6 +191,7 @@ bool operator==(Wrap<Mixed>, StringData) TIGHTDB_NOEXCEPT;
bool operator!=(Wrap<Mixed>, StringData) TIGHTDB_NOEXCEPT;
bool operator==(StringData, Wrap<Mixed>) TIGHTDB_NOEXCEPT;
bool operator!=(StringData, Wrap<Mixed>) TIGHTDB_NOEXCEPT;
/*
bool operator==(Wrap<Mixed>, const char* c_str) TIGHTDB_NOEXCEPT;
bool operator!=(Wrap<Mixed>, const char* c_str) TIGHTDB_NOEXCEPT;
bool operator==(const char* c_str, Wrap<Mixed>) TIGHTDB_NOEXCEPT;
Expand All @@ -197,6 +200,7 @@ bool operator==(Wrap<Mixed>, char* c_str) TIGHTDB_NOEXCEPT;
bool operator!=(Wrap<Mixed>, char* c_str) TIGHTDB_NOEXCEPT;
bool operator==(char* c_str, Wrap<Mixed>) TIGHTDB_NOEXCEPT;
bool operator!=(char* c_str, Wrap<Mixed>) TIGHTDB_NOEXCEPT;
*/

// Compare mixed with binary data
bool operator==(Wrap<Mixed>, BinaryData) TIGHTDB_NOEXCEPT;
Expand Down Expand Up @@ -493,6 +497,7 @@ inline bool operator!=(StringData a, Wrap<Mixed> b) TIGHTDB_NOEXCEPT
return type_String != Mixed(b).get_type() || a != Mixed(b).get_string();
}

/*
inline bool operator==(Wrap<Mixed> a, const char* b) TIGHTDB_NOEXCEPT
{
return a == StringData(b);
Expand Down Expand Up @@ -532,6 +537,7 @@ inline bool operator!=(char* a, Wrap<Mixed> b) TIGHTDB_NOEXCEPT
{
return StringData(a) != b;
}
*/


// Compare mixed with binary data
Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ void Spec::Verify() const
TIGHTDB_ASSERT(column_count <= m_spec.size());
}

void Spec::to_dot(std::ostream& out, const char*) const
void Spec::to_dot(std::ostream& out, StringData) const
{
const size_t ref = m_specSet.GetRef();

Expand Down
2 changes: 1 addition & 1 deletion src/tightdb/spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Spec {

#ifdef TIGHTDB_DEBUG
void Verify() const; // Must be upper case to avoid conflict with macro in ObjC
void to_dot(std::ostream& out, const char* title=NULL) const;
void to_dot(std::ostream& out, StringData title = StringData()) const;
#endif // TIGHTDB_DEBUG

private:
Expand Down
3 changes: 2 additions & 1 deletion src/tightdb/string_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ namespace tightdb {
/// other way attempt to manage the lifetime of it.
///
/// \sa BinaryData
struct StringData {
class StringData {
public:
StringData() TIGHTDB_NOEXCEPT: m_data(0), m_size(0) {}
StringData(const char* d, std::size_t s) TIGHTDB_NOEXCEPT: m_data(d), m_size(s) {}

Expand Down
4 changes: 2 additions & 2 deletions src/tightdb/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ void Table::to_dot(std::ostream& out, StringData title) const
out << " label = \"TopLevelTable";
if (0 < title.size()) out << "\\n'" << title << "'";
out << "\";" << endl;
m_top.ToDot(out, "table_top");
// m_top.ToDot(out, "table_top");
const Spec& specset = get_spec();
specset.to_dot(out);
}
Expand All @@ -2662,7 +2662,7 @@ void Table::to_dot(std::ostream& out, StringData title) const

void Table::ToDotInternal(std::ostream& out) const
{
m_columns.ToDot(out, "columns");
// m_columns.ToDot(out, "columns");

// Columns
const size_t column_count = get_column_count();
Expand Down

0 comments on commit 4452403

Please sign in to comment.