mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Update local dependencies
This commit is contained in:
parent
885a63b837
commit
434a775202
2667
include/inja.hpp
2667
include/inja.hpp
File diff suppressed because it is too large
Load Diff
@ -76,8 +76,14 @@
|
||||
#ifndef JPCRE2_USE_FUNCTION_POINTER_CALLBACK
|
||||
#include <functional> // std::function
|
||||
#endif
|
||||
#endif
|
||||
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
|
||||
#define JPCRE2_USE_MINIMUM_CXX_17 1
|
||||
#include <optional>
|
||||
#else
|
||||
#define JPCRE2_USE_MINIMUM_CXX_11 0
|
||||
#ifdef JPCRE2_UNSET_CAPTURES_NULL
|
||||
#error JPCRE2_UNSET_CAPTURES_NULL requires C++17
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define JPCRE2_UNUSED(x) ((void)(x))
|
||||
@ -194,7 +200,7 @@ static inline void _jvassert(bool cond, char const * name, const char* f, size_t
|
||||
|
||||
static inline std::string _tostdstring(unsigned x){
|
||||
char buf[128];
|
||||
int written = std::sprintf(buf, "%u", x);
|
||||
int written = std::snprintf(buf, 128, "%u", x);
|
||||
return (written > 0) ? std::string(buf, buf + written) : std::string();
|
||||
}
|
||||
|
||||
@ -1197,7 +1203,7 @@ template<> inline std::basic_string<char> MSG<char>::INVALID_MODIFIER(){ return
|
||||
template<> inline std::basic_string<wchar_t> MSG<wchar_t>::INVALID_MODIFIER(){ return L"Invalid modifier: "; }
|
||||
template<> inline std::basic_string<char> MSG<char>::INSUFFICIENT_OVECTOR(){ return "ovector wasn't big enough"; }
|
||||
template<> inline std::basic_string<wchar_t> MSG<wchar_t>::INSUFFICIENT_OVECTOR(){ return L"ovector wasn't big enough"; }
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<> inline std::basic_string<char16_t> MSG<char16_t>::INVALID_MODIFIER(){ return u"Invalid modifier: "; }
|
||||
template<> inline std::basic_string<char32_t> MSG<char32_t>::INVALID_MODIFIER(){ return U"Invalid modifier: "; }
|
||||
template<> inline std::basic_string<char16_t> MSG<char16_t>::INSUFFICIENT_OVECTOR(){ return u"ovector wasn't big enough"; }
|
||||
@ -1230,7 +1236,7 @@ template<> inline std::basic_string<char32_t> MSG<char32_t>::INSUFFICIENT_OVECTO
|
||||
///```cpp
|
||||
///typedef jpcre2::select<Char_T> jp;
|
||||
///```
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map=std::map>
|
||||
#else
|
||||
template<typename Char_T>
|
||||
@ -1252,7 +1258,7 @@ struct select{
|
||||
///char32_t | std::u32string (>=C++11)
|
||||
typedef typename std::basic_string<Char_T> String;
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
///Map for Named substrings.
|
||||
typedef class Map<String, String> MapNas;
|
||||
///Substring name to Substring number map.
|
||||
@ -1268,7 +1274,11 @@ struct select{
|
||||
typedef MapNtN MapNtn;
|
||||
|
||||
///Vector for Numbered substrings (Sub container).
|
||||
#ifdef JPCRE2_UNSET_CAPTURES_NULL
|
||||
typedef typename std::vector<std::optional<String>> NumSub;
|
||||
#else
|
||||
typedef typename std::vector<String> NumSub;
|
||||
#endif
|
||||
///Vector of matches with named substrings.
|
||||
typedef typename std::vector<MapNas> VecNas;
|
||||
///Vector of substring name to substring number map.
|
||||
@ -1449,7 +1459,7 @@ struct select{
|
||||
onlyCopy(rm);
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
void deepMove(RegexMatch& rm){
|
||||
m_subject = std::move_if_noexcept(rm.m_subject);
|
||||
onlyCopy(rm);
|
||||
@ -1498,7 +1508,7 @@ struct select{
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
///@overload
|
||||
///...
|
||||
///Move constructor.
|
||||
@ -1579,7 +1589,7 @@ struct select{
|
||||
/// Returns the last error message
|
||||
///@return Last error message
|
||||
virtual String getErrorMessage() const {
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
return select<Char, Map>::getErrorMessage(error_number, error_offset);
|
||||
#else
|
||||
return select<Char>::getErrorMessage(error_number, error_offset);
|
||||
@ -2044,14 +2054,18 @@ struct select{
|
||||
///@param ntn jp::MapNtN map.
|
||||
///@return total match (group 0) of current match.
|
||||
static String fill(NumSub const &num, MapNas const &nas, MapNtn const &ntn){
|
||||
#ifdef JPCRE2_UNSET_CAPTURES_NULL
|
||||
return *num[0];
|
||||
#else
|
||||
return num[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
//prevent object instantiation.
|
||||
callback();
|
||||
callback(callback const &);
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
callback(callback&&);
|
||||
#endif
|
||||
~callback();
|
||||
@ -2219,7 +2233,7 @@ struct select{
|
||||
onlyCopy(me);
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
void deepMove(MatchEvaluator& me){
|
||||
vec_num = std::move_if_noexcept(me.vec_num);
|
||||
vec_nas = std::move_if_noexcept(me.vec_nas);
|
||||
@ -2391,7 +2405,7 @@ struct select{
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
|
||||
///@overload
|
||||
/// ...
|
||||
@ -2957,7 +2971,7 @@ struct select{
|
||||
onlyCopy(rr);
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
void deepMove(RegexReplace& rr){
|
||||
r_subject = std::move_if_noexcept(rr.r_subject);
|
||||
onlyCopy(rr);
|
||||
@ -3005,7 +3019,7 @@ struct select{
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
|
||||
///@overload
|
||||
///...
|
||||
@ -3080,7 +3094,7 @@ struct select{
|
||||
/// Returns the last error message
|
||||
///@return Last error message
|
||||
String getErrorMessage() const {
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
return select<Char, Map>::getErrorMessage(error_number, error_offset);
|
||||
#else
|
||||
return select<Char>::getErrorMessage(error_number, error_offset);
|
||||
@ -3619,7 +3633,7 @@ struct select{
|
||||
: freeRegexMemory();
|
||||
}
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
|
||||
void deepMove(Regex& r) {
|
||||
pat_str = std::move_if_noexcept(r.pat_str);
|
||||
@ -3740,7 +3754,7 @@ struct select{
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
|
||||
|
||||
/// @overload
|
||||
@ -3895,6 +3909,15 @@ struct select{
|
||||
return pat_str_ptr;
|
||||
}
|
||||
|
||||
///Get number of captures from compiled code.
|
||||
///@return New line option value or 0.
|
||||
Uint getNumCaptures() {
|
||||
if(!code) return 0;
|
||||
Uint numCaptures = 0;
|
||||
int ret = Pcre2Func<sizeof( Char_T ) * CHAR_BIT>::pattern_info(code, PCRE2_INFO_CAPTURECOUNT, &numCaptures);
|
||||
if(ret < 0) error_number = ret;
|
||||
return numCaptures;
|
||||
}
|
||||
|
||||
/// Calculate modifier string from PCRE2 and JPCRE2 options and return it.
|
||||
///
|
||||
@ -3944,7 +3967,7 @@ struct select{
|
||||
/// Returns the last error message
|
||||
///@return Last error message
|
||||
String getErrorMessage() const {
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
return select<Char, Map>::getErrorMessage(error_number, error_offset);
|
||||
#else
|
||||
return select<Char>::getErrorMessage(error_number, error_offset);
|
||||
@ -4388,7 +4411,7 @@ struct select{
|
||||
//prevent object instantiation of select class
|
||||
select();
|
||||
select(select const &);
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
select(select&&);
|
||||
#endif
|
||||
~select();
|
||||
@ -4417,7 +4440,7 @@ inline void jpcre2::ModifierTable::parseModifierTable(std::string& tabjs, VecOpt
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
void jpcre2::select<Char_T, Map>::Regex::compile() {
|
||||
#else
|
||||
@ -4458,7 +4481,7 @@ void jpcre2::select<Char_T>::Regex::compile() {
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
typename jpcre2::select<Char_T, Map>::String jpcre2::select<Char_T, Map>::MatchEvaluator::replace(bool do_match, Uint replace_opts, SIZE_T * counter) {
|
||||
#else
|
||||
@ -4488,7 +4511,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::MatchEvaluator::
|
||||
SIZE_T last = vec_eoff.size();
|
||||
last = (last>0)?last-1:0;
|
||||
JPCRE2_ASSERT(vec_eoff[last] <= RegexMatch::getSubject().size(), "ValueError: subject string is not of the required size, may be it's changed!!!\
|
||||
If you are using esisting match data, try a new match.");
|
||||
If you are using existing match data, try a new match.");
|
||||
|
||||
//loop through the matches
|
||||
for(SIZE_T i=0;i<mcount;++i){
|
||||
@ -4526,7 +4549,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::MatchEvaluator::
|
||||
//second part
|
||||
///the matched part is the subject
|
||||
//~ Pcre2Sptr subject = (Pcre2Sptr) RegexMatch::getSubjectPointer()->c_str();
|
||||
//substr(vec_soff[i], vec_eoff[i] - vec_soff[i]).c_str();//->substr(vec_soff[i], vec_eoff[i]-vec_soff[i]);
|
||||
//substr(vec_soff[i], vec_eoff[i] - vec_soff[i]).c_str();
|
||||
Pcre2Sptr subject = r_subject_ptr + vec_soff[i];
|
||||
PCRE2_SIZE subject_length = vec_eoff[i] - vec_soff[i];
|
||||
|
||||
@ -4586,7 +4609,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::MatchEvaluator::
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
typename jpcre2::select<Char_T, Map>::String jpcre2::select<Char_T, Map>::MatchEvaluator::nreplace(bool do_match, Uint jo, SIZE_T* counter){
|
||||
#else
|
||||
@ -4605,7 +4628,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::MatchEvaluator::
|
||||
SIZE_T last = vec_eoff.size();
|
||||
last = (last>0)?last-1:0;
|
||||
JPCRE2_ASSERT(vec_eoff[last] <= RegexMatch::getSubject().size(), "ValueError: subject string is not of the required size, may be it's changed!!!\
|
||||
If you are using esisting match data, try a new match.");
|
||||
If you are using existing match data, try a new match.");
|
||||
|
||||
//loop through the matches
|
||||
for(SIZE_T i=0;i<mcount;++i){
|
||||
@ -4649,7 +4672,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::MatchEvaluator::
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
typename jpcre2::select<Char_T, Map>::String jpcre2::select<Char_T, Map>::RegexReplace::replace() {
|
||||
#else
|
||||
@ -4713,7 +4736,7 @@ typename jpcre2::select<Char_T>::String jpcre2::select<Char_T>::RegexReplace::re
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
bool jpcre2::select<Char_T, Map>::RegexMatch::getNumberedSubstrings(int rc, Pcre2Sptr subject, PCRE2_SIZE* ovector, uint32_t ovector_count) {
|
||||
#else
|
||||
@ -4724,16 +4747,22 @@ bool jpcre2::select<Char_T>::RegexMatch::getNumberedSubstrings(int rc, Pcre2Sptr
|
||||
uint32_t rcu = rc;
|
||||
num_sub.reserve(rcu); //we know exactly how many elements it will have.
|
||||
uint32_t i;
|
||||
for (i = 0u; i < rcu; i++)
|
||||
num_sub.push_back(String((Char*)(subject + ovector[2*i]), ovector[2*i+1] - ovector[2*i]));
|
||||
for (uint32_t j = i; j < ovector_count; j++)
|
||||
num_sub.push_back(String());
|
||||
for (i = 0u; i < ovector_count; i++) {
|
||||
if (ovector[2*i] != PCRE2_UNSET)
|
||||
num_sub.push_back(String((Char*)(subject + ovector[2*i]), ovector[2*i+1] - ovector[2*i]));
|
||||
else
|
||||
#ifdef JPCRE2_UNSET_CAPTURES_NULL
|
||||
num_sub.push_back(std::nullopt);
|
||||
#else
|
||||
num_sub.push_back(String());
|
||||
#endif
|
||||
}
|
||||
vec_num->push_back(num_sub); //this function shouldn't be called if this vector is null
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
bool jpcre2::select<Char_T, Map>::RegexMatch::getNamedSubstrings(int namecount, int name_entry_size,
|
||||
Pcre2Sptr name_table,
|
||||
@ -4771,7 +4800,7 @@ bool jpcre2::select<Char_T>::RegexMatch::getNamedSubstrings(int namecount, int n
|
||||
}
|
||||
|
||||
|
||||
#if JPCRE2_USE_MINIMUM_CXX_11
|
||||
#ifdef JPCRE2_USE_MINIMUM_CXX_11
|
||||
template<typename Char_T, template<typename...> class Map>
|
||||
jpcre2::SIZE_T jpcre2::select<Char_T, Map>::RegexMatch::match() {
|
||||
#else
|
||||
@ -5113,6 +5142,11 @@ jpcre2::SIZE_T jpcre2::select<Char_T>::RegexMatch::match() {
|
||||
///Using the standard `NDEBUG` macro will have the same effect,
|
||||
///but it is recommended that you use `JPCRE2_NDEBUG` to strip out debug codes specifically for this library.
|
||||
|
||||
|
||||
///@def JPCRE2_UNSET_CAPTURES_NULL
|
||||
///Define to change the type of NumSub so that captures are recorded
|
||||
///with std::optional. It is undefined by default. This feature requires C++17.
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -17,9 +17,9 @@
|
||||
|
||||
namespace inja
|
||||
{
|
||||
void convert_dot_to_json_pointer(nonstd::string_view dot, std::string& out)
|
||||
void convert_dot_to_json_pointer(std::string_view dot, std::string& out)
|
||||
{
|
||||
out = JsonNode::convert_dot_to_json_ptr(dot);
|
||||
out = DataNode::convert_dot_to_ptr(dot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user