src/xs/KeyProxy.h

filter: Statementstmt 0.0% 0 / 1 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 3 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/xs/Io.h ↑ Summary src/xs/Object.h »
1 #pragma once
2 #include <xs/Scalar.h>
3  
4 namespace xs {
5  
6 struct Sub; struct Hash; struct Array;
7  
8 struct KeyProxy : Scalar {
9 0 ▶ KeyProxy (SV** ptr, bool nullok) : Scalar(), ptr(ptr), nullok(nullok) { set(*ptr); }
Branch: 1 branch
BranchTrueFalseTotal
KeyProxy (SV** ptr, bool nullok) : Scalar(), ptr(ptr), nullok(nullok) { set(*ptr); } 0 0 0
10 KeyProxy (const KeyProxy&) = default;
11 KeyProxy (KeyProxy&&) = default;
12  
13 KeyProxy& operator= (std::nullptr_t) { return operator=(Scalar()); }
14 KeyProxy& operator= (const KeyProxy& v) { return operator=((Scalar)v); }
15 KeyProxy& operator= (const Scalar& val) {
16 Scalar::operator=(val);
17 SV* newsv = val;
18 if (nullok || newsv) SvREFCNT_inc_simple_void(newsv);
19 else newsv = newSV(0);
20 auto old = *ptr;
21 *ptr = newsv;
22 SvREFCNT_dec(old);
23 return *this;
24 }
25 KeyProxy& operator= (SV* v) { return operator=(Scalar(v)); }
26 KeyProxy& operator= (const Sv& v) { return operator=(Scalar(v)); }
27 KeyProxy& operator= (const Array&) = delete;
28 KeyProxy& operator= (const Hash&) = delete;
29 KeyProxy& operator= (const Sub&) = delete;
30 KeyProxy& operator= (const Io&) = delete;
31  
32 template <typename T, typename = panda::enable_if_arithmetic_t<T>>
33 KeyProxy operator[] (T key) { return _geti(key); }
34 KeyProxy operator[] (const panda::string_view& key);
35  
36 private:
37 SV** ptr;
38 bool nullok;
39
40 KeyProxy _geti (size_t key);
41 };
42  
43 }
« src/xs/Io.h ↑ Summary src/xs/Object.h »