summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-03-02 09:00:43 +0000
committerChris Wilson <chris+github@qwirx.com>2014-03-02 09:00:43 +0000
commit7723643183f186fc0d5064755d8ba825cb8755cb (patch)
tree93f68a1f479dee47caaa7fad73170c9bea2de6b8 /lib
parent96a7fb08056e4a8a758516c16ababf8705c17488 (diff)
Replace most of APPLY_DELTA macro with a new method.
Using methods instead of macros where possible makes debugging easier. Especially long macros like this one.
Diffstat (limited to 'lib')
-rw-r--r--lib/backupstore/BackupStoreInfo.cpp36
-rw-r--r--lib/backupstore/BackupStoreInfo.h3
2 files changed, 24 insertions, 15 deletions
diff --git a/lib/backupstore/BackupStoreInfo.cpp b/lib/backupstore/BackupStoreInfo.cpp
index bfacc6e6..dd120c86 100644
--- a/lib/backupstore/BackupStoreInfo.cpp
+++ b/lib/backupstore/BackupStoreInfo.cpp
@@ -452,22 +452,28 @@ int BackupStoreInfo::ReportChangesTo(BackupStoreInfo& rOldInfo)
return numChanges;
}
-#define APPLY_DELTA(field, delta) \
- if(mReadOnly) \
- { \
- THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) \
- } \
- \
- if((field + delta) < 0) \
- { \
- THROW_EXCEPTION_MESSAGE(BackupStoreException, \
- StoreInfoBlockDeltaMakesValueNegative, \
- "Failed to reduce " << #field << " from " << \
- field << " by " << delta); \
- } \
- \
- field += delta; \
+void BackupStoreInfo::ApplyDelta(int64_t& field, const std::string& field_name,
+ const int64_t delta)
+{
+ if(mReadOnly)
+ {
+ THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly);
+ }
+
+ if((field + delta) < 0)
+ {
+ THROW_EXCEPTION_MESSAGE(BackupStoreException,
+ StoreInfoBlockDeltaMakesValueNegative,
+ "Failed to reduce " << field_name << " from " <<
+ field << " by " << delta);
+ }
+
+ field += delta;
mIsModified = true;
+}
+
+#define APPLY_DELTA(field, delta) \
+ ApplyDelta(field, #field, delta)
// --------------------------------------------------------------------------
//
diff --git a/lib/backupstore/BackupStoreInfo.h b/lib/backupstore/BackupStoreInfo.h
index cb9f8f32..1eb67894 100644
--- a/lib/backupstore/BackupStoreInfo.h
+++ b/lib/backupstore/BackupStoreInfo.h
@@ -196,6 +196,9 @@ private:
std::vector<int64_t> mDeletedDirectories;
bool mAccountEnabled;
CollectInBufferStream mExtraData;
+
+ void ApplyDelta(int64_t& field, const std::string& field_name,
+ const int64_t delta);
};
#endif // BACKUPSTOREINFO__H