aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/scimpl.h
blob: 4f68f16290f7789cfb76a5a1c78147b963b5267c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
#pragma once

#include "scheme.h"

#include <util/stream/output.h>

namespace NSc {
    struct TValue::TScCore : TAtomicRefCount<TScCore, TDestructor>, TNonCopyable {
        TPoolPtr Pool;
        double FloatNumber = 0;
        i64 IntNumber = 0;
        TStringBuf String;
        TDict Dict;
        TArray Array;
        TValue::EType ValueType = TValue::EType::Null;

        TScCore(TPoolPtr& p)
            : Pool(p)
            , Dict(Pool->Get())
            , Array(Pool->Get())
        {
        }

        bool IsNull() const {
            return TValue::EType::Null == ValueType;
        }

        bool IsBool() const {
            return TValue::EType::Bool == ValueType;
        }

        bool IsIntNumber() const {
            return TValue::EType::IntNumber == ValueType || IsBool();
        }

        bool IsNumber() const {
            return TValue::EType::FloatNumber == ValueType || IsIntNumber();
        }

        bool IsString() const {
            return TValue::EType::String == ValueType;
        }

        bool IsArray() const {
            return TValue::EType::Array == ValueType;
        }

        bool IsDict() const {
            return TValue::EType::Dict == ValueType;
        }

        bool HasChildren() const {
            return GetDict().size() + GetArray().size();
        }

        void SetNull() {
            ValueType = TValue::EType::Null;
        }

        void SetArray() {
            if (Y_LIKELY(IsArray())) {
                return;
            }

            ValueType = TValue::EType::Array;
            Array.clear();
        }

        void SetDict() {
            if (Y_LIKELY(IsDict())) {
                return;
            }

            ValueType = TValue::EType::Dict;
            Dict.clear();
        }

        void SetNumber(double n) {
            ValueType = TValue::EType::FloatNumber;
            FloatNumber = n;
        }

        void SetIntNumber(i64 n) {
            ValueType = TValue::EType::IntNumber;
            IntNumber = n;
        }

        void SetBool(bool b) {
            ValueType = TValue::EType::Bool;
            IntNumber = b;
        }

        void SetString(TStringBuf s) {
            SetOwnedString(Pool->AppendBuf(s));
        }

        void SetOwnedString(TStringBuf s) {
            ValueType = TValue::EType::String;
            String = s;
        }

        double& GetNumberMutable(double defaultnum) {
            switch (ValueType) {
                case TValue::EType::Bool:
                    SetNumber(bool(IntNumber));
                    break;
                case TValue::EType::IntNumber:
                    SetNumber(IntNumber);
                    break;
                case TValue::EType::FloatNumber:
                    break;
                default:
                    SetNumber(defaultnum);
                    break;
            }

            return FloatNumber;
        }

        i64& GetIntNumberMutable(i64 defaultnum) {
            switch (ValueType) {
                case TValue::EType::Bool:
                    SetIntNumber(bool(IntNumber));
                    break;
                case TValue::EType::IntNumber:
                    break;
                case TValue::EType::FloatNumber:
                    SetIntNumber(FloatNumber);
                    break;
                default:
                    SetIntNumber(defaultnum);
                    break;
            }

            return IntNumber;
        }

        void ClearArray() {
            if (!IsArray()) {
                return;
            }

            Array.clear();
        }

        void ClearDict() {
            if (!IsDict()) {
                return;
            }

            Dict.clear();
        }

        double GetNumber(double d = 0) const {
            switch (ValueType) {
                case TValue::EType::Bool:
                    return (bool)IntNumber;
                case TValue::EType::IntNumber:
                    return IntNumber;
                case TValue::EType::FloatNumber:
                    return FloatNumber;
                default:
                    return d;
            }
        }

        i64 GetIntNumber(i64 n = 0) const {
            switch (ValueType) {
                case TValue::EType::Bool:
                    return (bool)IntNumber;
                case TValue::EType::IntNumber:
                    return IntNumber;
                case TValue::EType::FloatNumber:
                    return FloatNumber;
                default:
                    return n;
            }
        }

        bool GetBool(bool b = false) const {
            return GetIntNumber(b);
        }

        TStringBuf GetString(TStringBuf s = TStringBuf()) const {
            return IsString() ? String : s;
        }

        const TArray& GetArray() const {
            return IsArray() ? Array : TValue::DefaultArray();
        }

        TArray& GetArrayMutable() {
            SetArray();
            return Array;
        }

        TDict& GetDictMutable() {
            SetDict();
            return Dict;
        }

        const TDict& GetDict() const {
            return IsDict() ? Dict : TValue::DefaultDict();
        }

        static void DoPush(TPoolPtr& p, TArray& a) {
            a.push_back(TValue(p));
            a.back().CopyOnWrite = false;
        }

        TValue& Push() {
            SetArray();
            DoPush(Pool, Array);
            return Array.back();
        }

        TValue Pop() {
            if (!IsArray() || Array.empty()) {
                return TValue::DefaultValue();
            }

            TValue v = Array.back();
            Array.pop_back();
            return v;
        }

        const TValue& Get(size_t key) const {
            return IsArray() && Array.size() > key ? Array[key] : TValue::DefaultValue();
        }

        TValue* GetNoAdd(size_t key) {
            return IsArray() && Array.size() > key ? &Array[key] : nullptr;
        }

        TValue& GetOrAdd(size_t key) {
            SetArray();
            for (size_t i = Array.size(); i <= key; ++i) {
                DoPush(Pool, Array);
            }

            return Array[key];
        }

        TValue& Back() {
            SetArray();

            if (Array.empty()) {
                DoPush(Pool, Array);
            }

            return Array.back();
        }

        TValue& Insert(size_t key) {
            SetArray();

            if (Array.size() <= key) {
                return GetOrAdd(key);
            } else {
                Array.insert(Array.begin() + key, TValue(Pool));
                Array[key].CopyOnWrite = false;
                return Array[key];
            }
        }

        TValue Delete(size_t key) {
            if (!IsArray() || Array.size() <= key) {
                return TValue::DefaultValue();
            }

            TValue v = Array[key];
            Array.erase(Array.begin() + key);
            return v;
        }

        const TValue& Get(TStringBuf key) const {
            if (!IsDict()) {
                return TValue::DefaultValue();
            }

            TDict::const_iterator it = Dict.find(key);
            return it != Dict.end() ? it->second : TValue::DefaultValue();
        }

        TValue* GetNoAdd(TStringBuf key) {
            if (!IsDict()) {
                return nullptr;
            }

            return Dict.FindPtr(key);
        }

        TValue& Add(TStringBuf key) {
            SetDict();
            TDict::iterator it = Dict.insert(std::make_pair(Pool->AppendBuf(key), TValue(Pool))).first;
            it->second.CopyOnWrite = false;
            return it->second;
        }

        TValue& GetOrAdd(TStringBuf key) {
            SetDict();
            TDict::insert_ctx ctx;
            TDict::iterator it = Dict.find(key, ctx);

            if (it == Dict.end()) {
                it = Dict.insert_direct(std::make_pair(Pool->AppendBuf(key), TValue(Pool)), ctx);
                it->second.CopyOnWrite = false;
            }

            return it->second;
        }

        TValue Delete(TStringBuf key) {
            if (!IsDict()) {
                return TValue::DefaultValue();
            }

            TDict::iterator it = Dict.find(key);

            if (it == Dict.end()) {
                return TValue::DefaultValue();
            }

            TValue v = it->second;
            Dict.erase(key);
            return v;
        }
    };

    TValue::TScCore* TValue::NewCore(TPoolPtr& p) {
        return new (p->Pool.Allocate<TScCore>()) TScCore(p);
    }

    TValue::TValue() {
        auto p = TPoolPtr(new NDefinitions::TPool);
        TheCore = NewCore(p);
    }

    TValue::TValue(double t)
        : TValue()
    {
        SetNumber(t);
    }

    TValue::TValue(unsigned long long t)
        : TValue()
    {
        SetIntNumber(t);
    }

    TValue::TValue(unsigned long t)
        : TValue()
    {
        SetIntNumber(t);
    }

    TValue::TValue(unsigned t)
        : TValue()
    {
        SetIntNumber(t);
    }

    TValue::TValue(long long t)
        : TValue()
    {
        SetIntNumber(t);
    }

    TValue::TValue(long t)
        : TValue()
    {
        SetIntNumber(t);
    }

    TValue::TValue(int t)
        : TValue()
    {
        SetIntNumber(t);
    }

    //TValue::TValue(bool t)
    //    : TValue()
    //{
    //    SetBool(t);
    //}

    TValue::TValue(TStringBuf t)
        : TValue()
    {
        SetString(t);
    }

    TValue::TValue(const char* t)
        : TValue()
    {
        SetString(t);
    }

    TValue::TValue(TValue& v)
        : TheCore(v.TheCore)
        , CopyOnWrite(v.CopyOnWrite)
    {
    }

    TValue::TValue(const TValue& v)
        : TheCore(v.TheCore)
        , CopyOnWrite(true)
    {
    }

    TValue::TValue(TValue&& v) noexcept
        : TheCore(std::move(v.TheCore))
        , CopyOnWrite(v.CopyOnWrite)
    {}

    TValue::operator double() const {
        return GetNumber();
    }

    TValue::operator float() const {
        return GetNumber();
    }

    TValue::operator long long() const {
        return GetIntNumber();
    }

    TValue::operator long() const {
        return GetIntNumber();
    }

    TValue::operator int() const {
        return GetIntNumber();
    }

    TValue::operator short() const {
        return GetIntNumber();
    }

    TValue::operator char() const {
        return GetIntNumber();
    }

    TValue::operator unsigned long long() const {
        return GetIntNumber();
    }

    TValue::operator unsigned long() const {
        return GetIntNumber();
    }

    TValue::operator unsigned() const {
        return GetIntNumber();
    }

    TValue::operator unsigned short() const {
        return GetIntNumber();
    }

    TValue::operator unsigned char() const {
        return GetIntNumber();
    }

    TValue::operator signed char() const {
        return GetIntNumber();
    }

    TValue::operator TStringBuf() const {
        return GetString();
    }

    TValue::operator const ::NSc::TArray&() const {
        return GetArray();
    }

    TValue::operator const ::NSc::TDict&() const {
        return GetDict();
    }

    TValue& TValue::operator=(double t) {
        return SetNumber(t);
    }

    TValue& TValue::operator=(unsigned long long t) {
        return SetIntNumber(t);
    }

    TValue& TValue::operator=(unsigned long t) {
        return SetIntNumber(t);
    }

    TValue& TValue::operator=(unsigned t) {
        return SetIntNumber(t);
    }

    TValue& TValue::operator=(long long t) {
        return SetIntNumber(t);
    }

    TValue& TValue::operator=(long t) {
        return SetIntNumber(t);
    }

    TValue& TValue::operator=(int t) {
        return SetIntNumber(t);
    }

    //TValue& TValue::operator=(bool t) {
    //    return SetBool(t);
    //}

    TValue& TValue::operator=(TStringBuf t) {
        return SetString(t);
    }

    TValue& TValue::operator=(const char* t) {
        return SetString(t);
    }

    TValue& TValue::operator=(TValue& v) & {
        if (!Same(*this, v)) {
            //Extend TheCore lifetime not to trigger possible v deletion via parent-child chain
            auto tmpCore = TheCore;
            TheCore = v.TheCore;
            CopyOnWrite = v.CopyOnWrite;
        }
        return *this;
    }

    TValue& TValue::operator=(const TValue& v) & {
        if (!Same(*this, v)) {
            //Extend TheCore lifetime not to trigger possible v deletion via parent-child chain
            auto tmpCore = TheCore;
            TheCore = v.TheCore;
            CopyOnWrite = true;
        }
        return *this;
    }

    TValue& TValue::operator=(TValue&& v) & noexcept {
        if (!Same(*this, v)) {
            //Extend TheCore lifetime not to trigger possible v deletion via parent-child chain
            auto tmpCore = TheCore;
            TheCore = std::move(v.TheCore);
            CopyOnWrite = v.CopyOnWrite;
        }
        return *this;
    }

    bool TValue::Has(size_t idx) const {
        return IsArray() && GetArray().size() > idx;
    }

    bool TValue::Has(TStringBuf s) const {
        return GetDict().contains(s);
    }

    TValue& TValue::GetOrAddUnsafe(size_t idx) {
        return CoreMutable().GetOrAdd(idx);
    }

    TValue& TValue::GetOrAdd(TStringBuf idx) {
        return CoreMutable().GetOrAdd(idx);
    }

    const TValue& TValue::Get(size_t idx) const {
        return Core().Get(idx);
    }

    TValue* TValue::GetNoAdd(size_t idx) {
        return CoreMutable().GetNoAdd(idx);
    }

    const TValue& TValue::Get(TStringBuf idx) const {
        return Core().Get(idx);
    }

    TValue* TValue::GetNoAdd(TStringBuf key) {
        return CoreMutable().GetNoAdd(key);
    }

    TValue& TValue::Back() {
        return CoreMutable().Back();
    }

    const TValue& TValue::Back() const {
        const TArray& arr = GetArray();
        return arr.empty() ? DefaultValue() : arr.back();
    }

    TValue TValue::Delete(size_t idx) {
        return CoreMutable().Delete(idx);
    }

    TValue TValue::Delete(TStringBuf idx) {
        return CoreMutable().Delete(idx);
    }

    TValue& TValue::AddAll(std::initializer_list<std::pair<TStringBuf, TValue>> t) {
        for (const auto& el : t) {
            Add(el.first) = el.second;
        }
        return *this;
    }

    TValue& TValue::InsertUnsafe(size_t idx) {
        return CoreMutable().Insert(idx);
    }

    template <class TIt>
    TValue& TValue::AppendAll(TIt begin, TIt end) {
        GetArrayMutable().AppendAll(begin, end);
        return *this;
    }

    template <class TColl>
    TValue& TValue::AppendAll(TColl&& coll) {
        return AppendAll(std::begin(coll), std::end(coll));
    }

    TValue& TValue::AppendAll(std::initializer_list<TValue> coll) {
        return AppendAll(coll.begin(), coll.end());
    }

    TValue& TValue::Push() {
        return CoreMutable().Push();
    }

    TValue TValue::Pop() {
        return CoreMutable().Pop();
    }

    TValue::EType TValue::GetType() const {
        return Core().ValueType;
    }

    bool TValue::IsNull() const {
        return Core().IsNull();
    }

    bool TValue::IsNumber() const {
        return Core().IsNumber();
    }

    bool TValue::IsIntNumber() const {
        return Core().IsIntNumber();
    }

    bool TValue::IsBool() const {
        return Core().IsBool();
    }

    bool TValue::IsString() const {
        return Core().IsString();
    }

    bool TValue::IsArray() const {
        return Core().IsArray();
    }

    bool TValue::IsDict() const {
        return Core().IsDict();
    }

    TValue& TValue::SetNumber(double i) {
        CoreMutableForSet().SetNumber(i);
        return *this;
    }

    TValue& TValue::SetIntNumber(i64 n) {
        CoreMutableForSet().SetIntNumber(n);
        return *this;
    }

    TValue& TValue::SetBool(bool val) {
        CoreMutableForSet().SetBool(val);
        return *this;
    }

    TValue& TValue::SetString(TStringBuf s) {
        CoreMutableForSet().SetString(s);
        return *this;
    }

    double TValue::GetNumber(double d) const {
        return Core().GetNumber(d);
    }

    i64 TValue::GetIntNumber(i64 n) const {
        return Core().GetIntNumber(n);
    }

    bool TValue::GetBool(bool b) const {
        return Core().GetBool(b);
    }

    double& TValue::GetNumberMutable(double defaultval) {
        return CoreMutable().GetNumberMutable(defaultval);
    }

    i64& TValue::GetIntNumberMutable(i64 defaultval) {
        return CoreMutable().GetIntNumberMutable(defaultval);
    }

    TStringBuf TValue::GetString(TStringBuf d) const {
        return Core().GetString(d);
    }

    TValue& TValue::SetArray() {
        CoreMutable().SetArray();
        return *this;
    }

    TValue& TValue::ClearArray() {
        CoreMutable().ClearArray();
        return *this;
    }

    TValue& TValue::SetDict() {
        CoreMutable().SetDict();
        return *this;
    }

    TValue& TValue::ClearDict() {
        CoreMutable().ClearDict();
        return *this;
    }

    const TArray& TValue::GetArray() const {
        return Core().GetArray();
    }

    TArray& TValue::GetArrayMutable() {
        return CoreMutable().GetArrayMutable();
    }

    const TDict& TValue::GetDict() const {
        return Core().GetDict();
    }

    TDict& TValue::GetDictMutable() {
        return CoreMutable().GetDictMutable();
    }

    size_t TValue::StringSize() const {
        return GetString().size();
    }

    size_t TValue::ArraySize() const {
        return GetArray().size();
    }

    size_t TValue::DictSize() const {
        return GetDict().size();
    }

    bool TValue::StringEmpty() const {
        return GetString().empty();
    }

    bool TValue::ArrayEmpty() const {
        return GetArray().empty();
    }

    bool TValue::DictEmpty() const {
        return GetDict().empty();
    }

    TValue::TValue(TPoolPtr& p)
        : TheCore(NewCore(p))
    {
    }

    TValue::TScCore& TValue::CoreMutable() {
        if (Y_UNLIKELY(!TheCore)) {
            *this = TValue();
        } else if (Y_UNLIKELY(CopyOnWrite) && Y_UNLIKELY(TheCore->RefCount() > 1)) {
            *this = Clone();
        }

        CopyOnWrite = false;

        return *TheCore;
    }

    TValue::TScCore& TValue::CoreMutableForSet() {
        if (Y_UNLIKELY(!TheCore) || Y_UNLIKELY(CopyOnWrite) && Y_UNLIKELY(TheCore->RefCount() > 1)) {
            *this = TValue();
        }

        CopyOnWrite = false;

        return *TheCore;
    }

    const TValue::TScCore& TValue::Core() const {
        return TheCore ? *TheCore : DefaultCore();
    }

    TValue& TValue::SetNull() {
        CoreMutableForSet().SetNull();
        return *this;
    }

    namespace NPrivate {
        int CompareStr(const NSc::TValue& a, TStringBuf b);

        int CompareInt(const NSc::TValue& a, i64 r);

        int CompareFloat(const NSc::TValue& a, double r);
    }

    bool operator==(const TValue& a, const TValue& b);

    bool operator!=(const TValue& a, const TValue& b);

    bool operator<=(const TValue&, const TValue&) = delete;
    bool operator>=(const TValue&, const TValue&) = delete;
    bool operator<(const TValue&, const TValue&) = delete;
    bool operator>(const TValue&, const TValue&) = delete;

#define LIBRARY_SCHEME_DECLARE_TVALUE_OPS(T, Impl) \
    bool operator==(const NSc::TValue& a, T b);    \
    bool operator==(T b, const NSc::TValue& a);    \
    bool operator!=(const NSc::TValue& a, T b);    \
    bool operator!=(T b, const NSc::TValue& a);    \
    bool operator<=(const NSc::TValue& a, T b);    \
    bool operator<=(T b, const NSc::TValue& a);    \
    bool operator>=(const NSc::TValue& a, T b);    \
    bool operator>=(T b, const NSc::TValue& a);    \
    bool operator<(const NSc::TValue& a, T b);     \
    bool operator<(T b, const NSc::TValue& a);     \
    bool operator>(const NSc::TValue& a, T b);     \
    bool operator>(T b, const NSc::TValue& a);

#define LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(T)            \
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(signed T, CompareInt) \
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(unsigned T, CompareInt)

    //LIBRARY_SCHEME_DECLARE_TVALUE_OPS(bool, CompareInt)
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(char, CompareInt)
    LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(char)
    LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(short)
    LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(int)
    LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(long)
    LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS(long long)

    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(float, CompareFloat)
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(double, CompareFloat)

    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(TStringBuf, CompareStr)
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const TString&, CompareStr)
    LIBRARY_SCHEME_DECLARE_TVALUE_OPS(const char* const, CompareStr)

#undef LIBRARY_SCHEME_DECLARE_TVALUE_OPS
#undef LIBRARY_SCHEME_DECLARE_TVALUE_INT_OPS

}