Skip to content

Commit 32f1606

Browse files
committed
added TokenList constructors which take a buffer
1 parent b71b3d3 commit 32f1606

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

simplecpp.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,20 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
476476
readfile(stream,filename,outputList);
477477
}
478478

479+
simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
480+
: frontToken(nullptr), backToken(nullptr), files(filenames)
481+
{
482+
StdCharBufStream stream(data, size);
483+
readfile(stream,filename,outputList);
484+
}
485+
486+
simplecpp::TokenList::TokenList(const char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
487+
: frontToken(nullptr), backToken(nullptr), files(filenames)
488+
{
489+
StdCharBufStream stream(reinterpret_cast<const unsigned char*>(data), size);
490+
readfile(stream,filename,outputList);
491+
}
492+
479493
simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
480494
: frontToken(nullptr), backToken(nullptr), files(filenames)
481495
{

simplecpp.h

Lines changed: 4 additions & 0 deletions
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)