Skip to content

Commit 809b624

Browse files
committed
added TokenList constructors for buffers which do not require a size argument
1 parent 5207325 commit 809b624

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

simplecpp.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,17 @@ namespace simplecpp {
236236
/** generates a token list from the given std::istream parameter */
237237
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
238238
#ifdef SIMPLECPP_UNSAFE_API
239+
/** generates a token list from the given buffer */
240+
template<size_t size>
241+
TokenList(const char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
242+
: TokenList(reinterpret_cast<const unsigned char*>(data), size-1, filenames, filename, outputList, 0)
243+
{}
244+
/** generates a token list from the given buffer */
245+
template<size_t size>
246+
TokenList(const unsigned char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
247+
: TokenList(data, size-1, filenames, filename, outputList, 0)
248+
{}
249+
239250
/** generates a token list from the given buffer */
240251
TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
241252
: TokenList(data, size, filenames, filename, outputList, 0)

0 commit comments

Comments
 (0)