mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion] Add Macro to log the storage content
This commit is contained in:
@@ -35,3 +35,7 @@ tests += $(addprefix ion/test/,\
|
||||
storage.cpp\
|
||||
utf8_decoder.cpp\
|
||||
)
|
||||
|
||||
ifdef ION_STORAGE_LOG
|
||||
SFLAGS += -DION_STORAGE_LOG=1
|
||||
endif
|
||||
@@ -48,6 +48,9 @@ public:
|
||||
bool operator!=(const Record & other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
#if ION_STORAGE_LOG
|
||||
void log();
|
||||
#endif
|
||||
uint32_t checksum();
|
||||
bool isNull() const {
|
||||
return m_fullNameCRC32 == 0;
|
||||
@@ -76,6 +79,11 @@ public:
|
||||
};
|
||||
|
||||
Storage();
|
||||
|
||||
#if ION_STORAGE_LOG
|
||||
void log();
|
||||
#endif
|
||||
|
||||
size_t availableSize();
|
||||
uint32_t checksum();
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <new>
|
||||
#if ION_STORAGE_LOG
|
||||
#include<iostream>
|
||||
#endif
|
||||
|
||||
namespace Ion {
|
||||
|
||||
@@ -49,6 +52,15 @@ Storage::Record::Record(const char * baseName, const char * extension) {
|
||||
new (this) Record(baseName, strlen(baseName), extension, strlen(extension));
|
||||
}
|
||||
|
||||
|
||||
#if ION_STORAGE_LOG
|
||||
|
||||
void Storage::Record::log() {
|
||||
std::cout << "Name: " << fullName() << std::endl;
|
||||
std::cout << " Value (" << value().size << "): " << (char *)value().buffer << "\n\n" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t Storage::Record::checksum() {
|
||||
uint32_t crc32Results[2];
|
||||
crc32Results[0] = m_fullNameCRC32;
|
||||
@@ -82,6 +94,15 @@ Storage::Storage() :
|
||||
overrideSizeAtPosition(m_buffer, 0);
|
||||
}
|
||||
|
||||
#if ION_STORAGE_LOG
|
||||
void Storage::log() {
|
||||
for (char * p : *this) {
|
||||
const char * currentName = fullNameOfRecordStarting(p);
|
||||
Record(currentName).log();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t Storage::availableSize() {
|
||||
return k_storageSize-(endBuffer()-m_buffer)-sizeof(record_size_t);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user