@@ -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))
@@ -66,17 +67,17 @@ class SimpleTokenizer : public Tokenizer {
6667
6768 /* *
6869 * Tokenize code
69- * @param code The code
70+ * @param data The code
7071 * @param cpp Indicates if the code is C++
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],
7577 bool cpp = true,
7678 const std::string &configuration = emptyString)
7779 {
78- std::istringstream istr (code);
79- if (!list.createTokens (istr, cpp ? " test.cpp" : " test.c" ))
80+ if (!list.createTokens (code, size-1 , cpp ? " test.cpp" : " test.c" ))
8081 return false ;
8182
8283 return simplifyTokens1 (configuration);
@@ -91,9 +92,9 @@ class SimpleTokenList
9192{
9293public:
9394 template <size_t size>
94- explicit SimpleTokenList (const char (&data )[size], Standards::Language lang = Standards::Language::CPP)
95+ explicit SimpleTokenList (const char (&code )[size], Standards::Language lang = Standards::Language::CPP)
9596 {
96- if (!list.createTokens (data , size-1 , lang))
97+ if (!list.createTokens (code , size-1 , lang))
9798 throw std::runtime_error (" creating tokens failed" );
9899 }
99100
0 commit comments