Skip to content

Commit a6615d4

Browse files
committed
added TokenList constructors for buffers which do not require a size argument
1 parent cd07cec commit a6615d4

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
@@ -237,6 +237,17 @@ namespace simplecpp {
237237
/** generates a token list from the given std::istream parameter */
238238
TokenList(std::istream &istr, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr);
239239
#ifdef SIMPLECPP_UNSAFE_API
240+
/** generates a token list from the given buffer */
241+
template<size_t size>
242+
TokenList(const char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
243+
: TokenList(reinterpret_cast<const unsigned char*>(data), size-1, filenames, filename, outputList, 0)
244+
{}
245+
/** generates a token list from the given buffer */
246+
template<size_t size>
247+
TokenList(const unsigned char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
248+
: TokenList(data, size-1, filenames, filename, outputList, 0)
249+
{}
250+
240251
/** generates a token list from the given buffer */
241252
TokenList(const unsigned char* data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
242253
: TokenList(data, size, filenames, filename, outputList, 0)

0 commit comments

Comments
 (0)