From db8eb54bd7239ff2b046fe34b1c8d692860c6b5b Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 30 Sep 2014 19:45:20 -0400 Subject: script: move ToString and ValueString out of the header --- src/script/script.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/script/script.cpp') diff --git a/src/script/script.cpp b/src/script/script.cpp index a5126e7cc..1ce8ddb6d 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -7,6 +7,16 @@ #include +namespace { +inline std::string ValueString(const std::vector& vch) +{ + if (vch.size() <= 4) + return strprintf("%d", CScriptNum(vch).getint()); + else + return HexStr(vch); +} +} // anon namespace + using namespace std; const char* GetOpName(opcodetype opcode) @@ -253,3 +263,26 @@ bool CScript::HasCanonicalPushes() const } return true; } + +std::string CScript::ToString() const +{ + std::string str; + opcodetype opcode; + std::vector vch; + const_iterator pc = begin(); + while (pc < end()) + { + if (!str.empty()) + str += " "; + if (!GetOp(pc, opcode, vch)) + { + str += "[error]"; + return str; + } + if (0 <= opcode && opcode <= OP_PUSHDATA4) + str += ValueString(vch); + else + str += GetOpName(opcode); + } + return str; +} -- cgit v1.2.3 From 85c579e3a63cf505d6cedc454755265572e97d3e Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 24 Sep 2014 23:32:36 -0400 Subject: script: add a slew of includes all around and drop includes from script.h Lots of files ended up with indirect includes from script.h. --- src/script/script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/script/script.cpp') diff --git a/src/script/script.cpp b/src/script/script.cpp index 1ce8ddb6d..3e19d0c2b 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -5,7 +5,8 @@ #include "script.h" -#include +#include "tinyformat.h" +#include "utilstrencodings.h" namespace { inline std::string ValueString(const std::vector& vch) -- cgit v1.2.3