| 1 | //===----------------------------------------------------------------------===// |
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/parser/keyword_helper.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/common/common.hpp" |
| 12 | |
| 13 | namespace duckdb { |
| 14 | |
| 15 | class KeywordHelper { |
| 16 | public: |
| 17 | //! Returns true if the given text matches a keyword of the parser |
| 18 | static bool IsKeyword(const string &text); |
| 19 | |
| 20 | static string EscapeQuotes(const string &text, char quote = '"'); |
| 21 | |
| 22 | //! Returns true if the given string needs to be quoted when written as an identifier |
| 23 | static bool RequiresQuotes(const string &text, bool allow_caps = true); |
| 24 | |
| 25 | //! Writes a string that is quoted |
| 26 | static string WriteQuoted(const string &text, char quote = '\''); |
| 27 | |
| 28 | //! Writes a string that is optionally quoted + escaped so it can be used as an identifier |
| 29 | static string WriteOptionallyQuoted(const string &text, char quote = '"', bool allow_caps = true); |
| 30 | }; |
| 31 | |
| 32 | } // namespace duckdb |
| 33 | |