Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
CScriptNum Class Reference

#include <script.h>

Public Member Functions

 CScriptNum (const int64_t &n)
 Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
 CScriptNum (const std::vector< unsigned char > &vch, bool fRequireMinimal, const size_t nMaxNumSize=nDefaultMaxNumSize)
bool operator== (const int64_t &rhs) const
auto operator<=> (const int64_t &rhs) const
bool operator== (const CScriptNum &rhs) const
auto operator<=> (const CScriptNum &rhs) const
CScriptNum operator+ (const int64_t &rhs) const
CScriptNum operator- (const int64_t &rhs) const
CScriptNum operator+ (const CScriptNum &rhs) const
CScriptNum operator- (const CScriptNum &rhs) const
CScriptNumoperator+= (const CScriptNum &rhs)
CScriptNumoperator-= (const CScriptNum &rhs)
CScriptNum operator& (const int64_t &rhs) const
CScriptNum operator& (const CScriptNum &rhs) const
CScriptNumoperator&= (const CScriptNum &rhs)
CScriptNum operator- () const
CScriptNumoperator= (const int64_t &rhs)
CScriptNumoperator+= (const int64_t &rhs)
CScriptNumoperator-= (const int64_t &rhs)
CScriptNumoperator&= (const int64_t &rhs)
int getint () const
int64_t GetInt64 () const
std::vector< unsigned char > getvch () const

Static Public Member Functions

static std::vector< unsigned char > serialize (const int64_t &value)

Static Public Attributes

static const size_t nDefaultMaxNumSize = 4

Static Private Member Functions

static int64_t set_vch (const std::vector< unsigned char > &vch)

Private Attributes

int64_t m_value

Detailed Description

Definition at line 226 of file script.h.

Constructor & Destructor Documentation

◆ CScriptNum() [1/2]

CScriptNum::CScriptNum ( const int64_t & n)
inlineexplicit

Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.

The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1], but results may overflow (and are valid as long as they are not used in a subsequent numeric operation). CScriptNum enforces those semantics by storing results as an int64 and allowing out-of-range values to be returned as a vector of bytes but throwing an exception if arithmetic is done or the result is interpreted as an integer.

Definition at line 238 of file script.h.

Here is the caller graph for this function:

◆ CScriptNum() [2/2]

CScriptNum::CScriptNum ( const std::vector< unsigned char > & vch,
bool fRequireMinimal,
const size_t nMaxNumSize = nDefaultMaxNumSize )
inlineexplicit

Definition at line 245 of file script.h.

Here is the call graph for this function:

Member Function Documentation

◆ getint()

int CScriptNum::getint ( ) const
inline

Definition at line 325 of file script.h.

Here is the caller graph for this function:

◆ GetInt64()

int64_t CScriptNum::GetInt64 ( ) const
inline

Definition at line 334 of file script.h.

Here is the caller graph for this function:

◆ getvch()

std::vector< unsigned char > CScriptNum::getvch ( ) const
inline

Definition at line 336 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&() [1/2]

CScriptNum CScriptNum::operator& ( const CScriptNum & rhs) const
inline

Definition at line 287 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&() [2/2]

CScriptNum CScriptNum::operator& ( const int64_t & rhs) const
inline

Definition at line 286 of file script.h.

Here is the call graph for this function:

◆ operator&=() [1/2]

CScriptNum & CScriptNum::operator&= ( const CScriptNum & rhs)
inline

Definition at line 289 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&=() [2/2]

CScriptNum & CScriptNum::operator&= ( const int64_t & rhs)
inline

Definition at line 319 of file script.h.

Here is the call graph for this function:

◆ operator+() [1/2]

CScriptNum CScriptNum::operator+ ( const CScriptNum & rhs) const
inline

Definition at line 280 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+() [2/2]

CScriptNum CScriptNum::operator+ ( const int64_t & rhs) const
inline

Definition at line 278 of file script.h.

Here is the call graph for this function:

◆ operator+=() [1/2]

CScriptNum & CScriptNum::operator+= ( const CScriptNum & rhs)
inline

Definition at line 283 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+=() [2/2]

CScriptNum & CScriptNum::operator+= ( const int64_t & rhs)
inline

Definition at line 303 of file script.h.

Here is the call graph for this function:

◆ operator-() [1/3]

CScriptNum CScriptNum::operator- ( ) const
inline

Definition at line 291 of file script.h.

Here is the call graph for this function:

◆ operator-() [2/3]

CScriptNum CScriptNum::operator- ( const CScriptNum & rhs) const
inline

Definition at line 281 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator-() [3/3]

CScriptNum CScriptNum::operator- ( const int64_t & rhs) const
inline

Definition at line 279 of file script.h.

Here is the call graph for this function:

◆ operator-=() [1/2]

CScriptNum & CScriptNum::operator-= ( const CScriptNum & rhs)
inline

Definition at line 284 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator-=() [2/2]

CScriptNum & CScriptNum::operator-= ( const int64_t & rhs)
inline

Definition at line 311 of file script.h.

Here is the call graph for this function:

◆ operator<=>() [1/2]

auto CScriptNum::operator<=> ( const CScriptNum & rhs) const
inline

Definition at line 276 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<=>() [2/2]

auto CScriptNum::operator<=> ( const int64_t & rhs) const
inline

Definition at line 273 of file script.h.

◆ operator=()

CScriptNum & CScriptNum::operator= ( const int64_t & rhs)
inline

Definition at line 297 of file script.h.

Here is the call graph for this function:

◆ operator==() [1/2]

bool CScriptNum::operator== ( const CScriptNum & rhs) const
inline

Definition at line 275 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==() [2/2]

bool CScriptNum::operator== ( const int64_t & rhs) const
inline

Definition at line 272 of file script.h.

◆ serialize()

std::vector< unsigned char > CScriptNum::serialize ( const int64_t & value)
inlinestatic

Definition at line 341 of file script.h.

Here is the caller graph for this function:

◆ set_vch()

int64_t CScriptNum::set_vch ( const std::vector< unsigned char > & vch)
inlinestaticprivate

Definition at line 375 of file script.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_value

int64_t CScriptNum::m_value
private

Definition at line 392 of file script.h.

◆ nDefaultMaxNumSize

const size_t CScriptNum::nDefaultMaxNumSize = 4
static

Definition at line 243 of file script.h.


The documentation for this class was generated from the following file: