@@ -43,7 +43,8 @@ namespace simplecpp {
4343// TODO: make Tokenizer private
4444class SimpleTokenizer : public Tokenizer {
4545public:
46- SimpleTokenizer (ErrorLogger& errorlogger, const char code[], bool cpp = true )
46+ template <size_t size>
47+ SimpleTokenizer (ErrorLogger& errorlogger, const char (&code)[size], bool cpp = true)
4748 : Tokenizer{s_settings, errorlogger}
4849 {
4950 if (!tokenize (code, cpp))
@@ -71,7 +72,20 @@ class SimpleTokenizer : public Tokenizer {
7172 * @param configuration E.g. "A" for code where "#ifdef A" is true
7273 * @return false if source code contains syntax errors
7374 */
74- bool tokenize (const char code[],
75+ template <size_t size>
76+ bool tokenize (const char (&code)[size],
77+ bool cpp = true,
78+ const std::string &configuration = emptyString)
79+ {
80+ std::istringstream istr (code);
81+ if (!list.createTokens (istr, cpp ? " test.cpp" : " test.c" ))
82+ return false ;
83+
84+ return simplifyTokens1 (configuration);
85+ }
86+
87+ // TODO: get rid of this
88+ bool tokenize (const std::string& code,
7589 bool cpp = true ,
7690 const std::string &configuration = emptyString)
7791 {
@@ -90,8 +104,8 @@ class SimpleTokenizer : public Tokenizer {
90104class SimpleTokenList
91105{
92106public:
93-
94- explicit SimpleTokenList (const char code[ ], Standards::Language lang = Standards::Language::CPP)
107+ template < size_t size>
108+ explicit SimpleTokenList (const char (& code)[size ], Standards::Language lang = Standards::Language::CPP)
95109 {
96110 std::istringstream iss (code);
97111 if (!list.createTokens (iss, lang))
0 commit comments