1#ifndef TEXTMATELIB_UTILS_H
2#define TEXTMATELIB_UTILS_H
14struct IOnigCaptureIndex;
18T clone(
const T& something);
20std::string mergeObjects(
const std::string& target,
const std::vector<std::string>& sources);
23std::string basename(
const std::string& path);
26int strcmp_custom(
const std::string& a,
const std::string& b);
27int strArrCmp(
const std::vector<std::string>* a,
const std::vector<std::string>* b);
30bool isValidHexColor(
const std::string& hex);
33std::string escapeRegExpCharacters(
const std::string& value);
36bool containsRTL(
const std::string& str);
39double performanceNow();
47 bool hasBackReferences;
48 std::string anchorCache_A0_G0;
49 std::string anchorCache_A0_G1;
50 std::string anchorCache_A1_G0;
51 std::string anchorCache_A1_G1;
53 RegexSource(
const std::string& regExpSource, RuleId ruleId_);
55 static bool hasCaptures(
const std::string* regexSource);
56 static std::string replaceCaptures(
const std::string& regexSource,
57 const std::string& captureSource,
58 const std::vector<IOnigCaptureIndex>& captureIndices);
60 std::string resolveBackReferences(
const std::string& lineText,
61 const std::vector<IOnigCaptureIndex>& captureIndices);
63 void buildAnchorCache();
64 std::string resolveAnchors(
bool allowA,
bool allowG)
const;
66 RegexSource* clone()
const;
70template<
typename TKey,
typename TValue>
73 std::map<TKey, TValue> cache;
74 std::function<TValue(
const TKey&)> fn;
77 CachedFn(std::function<TValue(
const TKey&)> func) : fn(func) {}
79 TValue get(
const TKey& key) {
80 auto it = cache.find(key);
81 if (it != cache.end()) {
84 TValue value = fn(key);
Core type definitions and interfaces for TextMateLib.