Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3155,6 +3155,9 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
mImpl->mIdMap.emplace(fileId, data);
mData.emplace_back(data);

if (mLoadCallback)
mLoadCallback(*data);

return {data, true};
}

Expand Down
8 changes: 8 additions & 0 deletions simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cctype>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iosfwd>
#include <list>
#include <map>
Expand Down Expand Up @@ -498,6 +499,12 @@ namespace simplecpp {
return mData.cend();
}

using load_callback_type = std::function<void (FileData &)>;

void set_load_callback(load_callback_type cb) {
mLoadCallback = std::move(cb);
}

private:
struct Impl;
std::unique_ptr<Impl> mImpl;
Expand All @@ -508,6 +515,7 @@ namespace simplecpp {

container_type mData;
name_map_type mNameMap;
load_callback_type mLoadCallback;
};

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