From 71a7916920584959f571c527bd7b0ccb86b069d5 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 27 Mar 2024 21:14:07 +0100 Subject: [PATCH] added `TokenList` constructor which takes a `std::string` --- simplecpp.cpp | 7 +++++++ simplecpp.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/simplecpp.cpp b/simplecpp.cpp index 1c006b02..6fdc03a9 100755 --- a/simplecpp.cpp +++ b/simplecpp.cpp @@ -476,6 +476,13 @@ simplecpp::TokenList::TokenList(std::istream &istr, std::vector &fi readfile(stream,filename,outputList); } +simplecpp::TokenList::TokenList(const std::string &str, std::vector &filenames, const std::string &filename, OutputList *outputList) + : frontToken(nullptr), backToken(nullptr), files(filenames) +{ + StdStringStream stream(str); + readfile(stream,filename,outputList); +} + simplecpp::TokenList::TokenList(const std::string &filename, std::vector &filenames, OutputList *outputList) : frontToken(nullptr), backToken(nullptr), files(filenames) { diff --git a/simplecpp.h b/simplecpp.h index 87238378..f627c278 100755 --- a/simplecpp.h +++ b/simplecpp.h @@ -198,6 +198,8 @@ namespace simplecpp { explicit TokenList(std::vector &filenames); /** generates a token list from the given std::istream parameter */ TokenList(std::istream &istr, std::vector &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr); + /** generates a token list from the given std::string parameter */ + TokenList(const std::string &str, std::vector &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr); /** generates a token list from the given filename parameter */ TokenList(const std::string &filename, std::vector &filenames, OutputList *outputList = nullptr); TokenList(const TokenList &other);