Skip to content

Commit ed258b7

Browse files
committed
Add file load callback
1 parent 3b3b30e commit ed258b7

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

simplecpp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,6 +3155,9 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
31553155
mImpl->mIdMap.emplace(fileId, data);
31563156
mData.emplace_back(data);
31573157

3158+
if (mLoadCallback)
3159+
mLoadCallback(*data);
3160+
31583161
return {data, true};
31593162
}
31603163

simplecpp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cctype>
1010
#include <cstdint>
1111
#include <cstring>
12+
#include <functional>
1213
#include <iosfwd>
1314
#include <list>
1415
#include <map>
@@ -498,6 +499,8 @@ namespace simplecpp {
498499
return mData.cend();
499500
}
500501

502+
using load_callback_type = std::function<void (FileData &)>;
503+
501504
private:
502505
struct Impl;
503506
std::unique_ptr<Impl> mImpl;
@@ -508,6 +511,7 @@ namespace simplecpp {
508511

509512
container_type mData;
510513
name_map_type mNameMap;
514+
load_callback_type mLoadCallback;
511515
};
512516

513517
/** Converts character literal (including prefix, but not ud-suffix) to long long value.

0 commit comments

Comments
 (0)