Skip to content

Commit 3a7aecd

Browse files
committed
added TokenList constructors which take a buffer [skip ci]
1 parent 4768d12 commit 3a7aecd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

simplecpp.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,20 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
485485
readfile(stream,filename,outputList);
486486
}
487487

488+
simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
489+
: frontToken(nullptr), backToken(nullptr), files(filenames)
490+
{
491+
StdCharBufStream stream(data, size);
492+
readfile(stream,filename,outputList);
493+
}
494+
495+
simplecpp::TokenList::TokenList(const char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
496+
: frontToken(nullptr), backToken(nullptr), files(filenames)
497+
{
498+
StdCharBufStream stream(reinterpret_cast<const unsigned char*>(data), size);
499+
readfile(stream,filename,outputList);
500+
}
501+
488502
simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
489503
: frontToken(nullptr), backToken(nullptr), files(filenames)
490504
{

simplecpp.h

+4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ namespace simplecpp {
198198
explicit TokenList(std::vector<std::string> &filenames);
199199
/** generates a token list from the given std::istream parameter */
200200
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
201+
/** generates a token list from the given buffer */
202+
TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
203+
/** generates a token list from the given buffer */
204+
TokenList(const char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
201205
/** generates a token list from the given filename parameter */
202206
TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList = nullptr);
203207
TokenList(const TokenList &other);

0 commit comments

Comments
 (0)