@@ -69,6 +69,30 @@ namespace simplecpp {
6969 enum cppstd_t : std::int8_t { CPPUnknown=-1 , CPP03, CPP11, CPP14, CPP17, CPP20, CPP23, CPP26 };
7070
7171 using TokenString = std::string;
72+
73+ #if defined(__cpp_lib_string_view)
74+ using View = std::string_view;
75+ #else
76+ struct View
77+ {
78+ View (const char * data, std::size_t size)
79+ : data_(data)
80+ , size_(size)
81+ {}
82+
83+ const char * data () const {
84+ return data_;
85+ }
86+
87+ std::size_t size () const {
88+ return size_;
89+ }
90+
91+ const char * data_;
92+ std::size_t size_;
93+ };
94+ #endif
95+
7296 class Macro ;
7397
7498 /* *
@@ -228,19 +252,10 @@ namespace simplecpp {
228252 TokenList (const unsigned char (&data)[size], std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
229253 : TokenList(data, size-1 , filenames, filename, outputList, 0 )
230254 {}
231-
232- /* * generates a token list from the given buffer */
233- TokenList (const unsigned char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
234- : TokenList(data, size, filenames, filename, outputList, 0 )
235- {}
236- /* * generates a token list from the given buffer */
237- TokenList (const char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
238- : TokenList(reinterpret_cast <const unsigned char *>(data), size, filenames, filename, outputList, 0)
239- {}
240255#endif
241- #if defined(__cpp_lib_string_view) && !defined(__cpp_lib_span)
256+ #if defined(SIMPLECPP_TOKENLIST_ALLOW_PTR) || (defined( __cpp_lib_string_view) && !defined(__cpp_lib_span) )
242257 /* * generates a token list from the given buffer */
243- TokenList (std::string_view data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
258+ TokenList (View data, std::vector<std::string> &filenames, const std::string &filename=std::string(), OutputList *outputList = nullptr)
244259 : TokenList(reinterpret_cast <const unsigned char *>(data.data()), data.size(), filenames, filename, outputList, 0)
245260 {}
246261#endif
0 commit comments