| 159 | |
| 160 | private: |
| 161 | static int64_t set_vch(const std::vector<unsigned char>& vch) |
| 162 | { |
| 163 | if (vch.empty()) |
| 164 | return 0; |
| 165 | |
| 166 | int64_t result = 0; |
| 167 | for (size_t i = 0; i != vch.size(); ++i) |
| 168 | result |= static_cast<int64_t>(vch[i]) << 8*i; |
| 169 | |
| 170 | // If the input vector's most significant byte is 0x80, remove it from |
| 171 | // the result's msb and return a negative. |
| 172 | if (vch.back() & 0x80) |
| 173 | return -((int64_t)(result & ~(0x80ULL << (8 * (vch.size() - 1))))); |
| 174 | |
| 175 | return result; |
| 176 | } |
| 177 | |
| 178 | int64_t m_value; |
| 179 | }; |