Skip to content

Commit 1895980

Browse files
committed
added TokenList constructors which take a buffer
1 parent 1cb98c8 commit 1895980

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
@@ -478,6 +478,20 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector<std::string> &fi
478478
readfile(stream,filename,outputList);
479479
}
480480

481+
simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
482+
: frontToken(nullptr), backToken(nullptr), files(filenames)
483+
{
484+
StdCharBufStream stream(data, size);
485+
readfile(stream,filename,outputList);
486+
}
487+
488+
simplecpp::TokenList::TokenList(const 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(reinterpret_cast<const unsigned char*>(data), size);
492+
readfile(stream,filename,outputList);
493+
}
494+
481495
simplecpp::TokenList::TokenList(const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
482496
: frontToken(nullptr), backToken(nullptr), files(filenames)
483497
{

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)