summaryrefslogtreecommitdiff
path: root/lib/backupstore/BackupStoreInfo.cpp
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/backupstore/BackupStoreInfo.cpp
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/backupstore/BackupStoreInfo.cpp')
-rw-r--r--lib/backupstore/BackupStoreInfo.cpp36
1 files changed, 21 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)
// --------------------------------------------------------------------------
//