zeroshade commented on code in PR #3876:
URL: https://github.com/apache/arrow-adbc/pull/3876#discussion_r2799791443
##########
c/driver_manager/adbc_driver_manager.cc:
##########
@@ -398,6 +417,91 @@ AdbcStatusCode LoadDriverFromRegistry(HKEY root, const
std::wstring& driver_name
}
#endif // _WIN32
+#define CHECK_STATUS(EXPR) \
+ if (auto _status = (EXPR); _status != ADBC_STATUS_OK) { \
+ return _status; \
+ }
+
+AdbcStatusCode ProcessProfileValue(std::string_view value, std::string& out,
+ struct AdbcError* error) {
+ if (value.empty()) {
+ SetError(error, "Profile value is null");
+ return ADBC_STATUS_INVALID_ARGUMENT;
+ }
+
+ std::regex pattern(R"(\{\{\s*([^{}]*?)\s*\}\})");
+ auto end_of_last_match = value.begin();
+ auto begin = std::regex_iterator(value.begin(), value.end(), pattern);
+ auto end = decltype(begin){};
+ std::match_results<std::string_view::iterator>::difference_type
pos_last_match = 0;
+
+ out.resize(0);
+ for (auto itr = begin; itr != end; ++itr) {
+ auto match = *itr;
+ auto pos_match = match.position();
+ auto diff = pos_match - pos_last_match;
+ auto start_match = end_of_last_match;
+ std::advance(start_match, diff);
+ if (pos_match > 0 && value[pos_match - 1] == '\\') {
Review Comment:
I'm open to any suggestions. I explicitly don't want to imply a full
templating language. Currently we won't match a single `{` only `{{`, as far as
I know, most templating languages don't actually provide a way to escape the
`{{` you just need to use an expression that *outputs* the `{{` like `{{ print
"{{" }}` etc. I also can't think of a reason offhand why someone would really
need to escape it. So I'm fine removing this escaping since the syntax is
funky. Up to you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]