1
0
This commit is contained in:
Scott E. Graves
2017-05-10 23:28:59 -05:00
parent 36530ac39d
commit a0813802c9
13 changed files with 7735 additions and 7660 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -8,12 +8,7 @@
NS_BEGIN(Sia)
NS_BEGIN(Api)
class CSiaTransaction;
typedef std::shared_ptr<CSiaTransaction> CSiaTransactionPtr;
typedef std::vector<CSiaTransactionPtr> CSiaTransactionList;
typedef std::shared_ptr<CSiaTransactionList> CSiaTransactionListPtr;
class CSiaDriveConfig;
class SIADRIVE_EXPORTABLE CSiaBase
{
public:
@@ -130,9 +125,6 @@ public:
Property(SiaCurrency, UnconfirmedBalance, public, private)
Property(SString, ReceiveAddress, public, private)
private:
CSiaTransactionListPtr _transList;
private:
virtual void Refresh(const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig);
@@ -142,7 +134,6 @@ public:
CSiaError<_SiaApiErrorCode> Lock();
CSiaError<_SiaApiErrorCode> Unlock(const SString& password);
CSiaError<_SiaApiErrorCode> Send(const SString& address, const SiaCurrency& amount);
CSiaTransactionListPtr GetTransactionHistory() const;
};
class SIADRIVE_EXPORTABLE _CSiaRenter :

View File

@@ -85,7 +85,7 @@ public:
}
};
typedef ttmath::UInt<32> Hastings;
typedef ttmath::UInt<256> Hastings;
typedef ttmath::Big<1, 30> SiaCurrency;
const std::uint8_t SIA_BLOCK_TIME_MINS = 10;
@@ -113,15 +113,7 @@ get_access:\
set_access:\
type Set##name(const type& value) { json_doc[#name] = value; return value; }\
protected:\
bool Check##name() { return json_doc.find(#name) != json_doc.end(); }
#define JProperty2(type, name, json_name, get_access, set_access, json_doc) \
get_access:\
type Get##name() const { return json_doc[#json_name].get<type>();}\
set_access:\
type Set##name(const type& value) { json_doc[#json_name] = value; return value; }\
protected:\
bool Check##name() { return json_doc.find(#json_name) != json_doc.end(); }
bool Check##name() { return json_doc.find(#name) != json_doc.end(); }
#define JPropertyCb(type, name, get_access, set_access, json_doc, cb) \
get_access:\
@@ -173,13 +165,6 @@ inline bool ApiSuccess(const T& t) {
return static_cast<bool>(t);
}
inline static SiaCurrency HastingsToSiaCurrency(const Hastings& value)
{
ttmath::Parser<SiaCurrency> parser;
parser.Parse((value.ToString() + " / (10 ^ 24)"));
return parser.stack[0].value;
}
inline static SiaCurrency HastingsStringToSiaCurrency(const SString& value)
{
ttmath::Parser<SiaCurrency> parser;

View File

@@ -1,63 +0,0 @@
#ifndef _SIATRANSACTION_H
#define _SIATRANSACTION_H
#include <siacommon.h>
NS_BEGIN(Sia)
NS_BEGIN(Api)
class SIADRIVE_EXPORTABLE CSiaTransaction
{
public:
class CSiaInput
{
public:
CSiaInput(const json& json);
private:
json _json;
JProperty2(std::string, FundType, fundtype, public, private, _json)
JProperty2(bool, WalletAddress, walletaddress, public, private, _json)
JProperty2(std::string, RelatedAddress, relatedaddress, public, private, _json)
JProperty2(std::string, Value, value, public, private, _json)
};
typedef std::shared_ptr<CSiaInput> CSiaInputPtr;
public:
class CSiaOutput
{
public:
CSiaOutput(const json& json);
private:
json _json;
JProperty2(std::string, FundType, fundtype, public, private, _json)
JProperty2(std::uint64_t, MaturityHeight, maturityheight, public, private, _json)
JProperty2(bool, WalletAddress, walletaddress, public, private, _json)
JProperty2(std::string, RelatedAddress, relatedaddress, public, private, _json)
JProperty2(std::string, Value, value, public, private, _json)
};
typedef std::shared_ptr<CSiaOutput> CSiaOutputPtr;
public:
CSiaTransaction(const json& json);
private:
json _json;
JProperty2(std::uint64_t, ConfirmationTimeStamp, confirmationtimestamp, public, private, _json)
JProperty2(std::uint64_t, ConfirmationHeight, confirmationheight, public, private, _json)
JProperty2(std::string, TransactionId, transactionid, public, private, _json)
Property(std::vector<CSiaInputPtr>, Inputs, public, private)
Property(std::vector<CSiaOutputPtr>, Outputs, public, private)
public:
SString GetDate() const;
SiaCurrency GetAmount() const;
};
NS_END(2)
#endif

View File

@@ -63,7 +63,7 @@ public:
#ifdef _UNICODE
static std::wstring ActiveString(const std::string& str)
{
return FromUtf8(str);
return std::move(FromUtf8(str));
}
static inline std::wstring ActiveString(const std::wstring& str)
@@ -73,7 +73,7 @@ public:
#else
static inline std::string ActiveString(const std::wstring& str)
{
return ToUtf8(str);
return std::move(ToUtf8(str));
}
static inline std::string ActiveString(const std::string& str)
@@ -84,22 +84,14 @@ public:
static inline std::string ToUtf8(const std::wstring &str)
{
if (str.length())
{
std::wstring_convert<deletable_facet<std::codecvt<wchar_t, char, std::mbstate_t>>, wchar_t> conv;
return conv.to_bytes(str);
}
return "";
std::wstring_convert<deletable_facet<std::codecvt<wchar_t, char, std::mbstate_t>>, wchar_t> conv;
return conv.to_bytes(str);
}
static inline std::wstring FromUtf8(const std::string &str)
{
if (str.length())
{
std::wstring_convert<deletable_facet<std::codecvt<wchar_t, char, std::mbstate_t>>, wchar_t> conv;
return conv.from_bytes(str);
}
return L"";
std::wstring_convert<deletable_facet<std::codecvt<wchar_t, char, std::mbstate_t>>, wchar_t> conv;
return conv.from_bytes(str);
}
static inline String &LeftTrim(String &s)
@@ -126,7 +118,7 @@ public:
static inline SString FromInt32(const std::int32_t &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline std::uint32_t ToUInt32(const SString &str)
@@ -136,7 +128,7 @@ public:
static inline SString FromUInt32(const std::uint32_t &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline std::int64_t ToInt64(const SString &str)
@@ -146,12 +138,12 @@ public:
static inline SString FromInt64(const std::int64_t &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline SString FromUInt64(const std::uint64_t &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline std::uint64_t ToUInt64(const SString &str)
@@ -166,7 +158,7 @@ public:
static inline SString FromUInt8(const std::uint8_t &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline float ToFloat(const SString &str)
@@ -176,7 +168,7 @@ public:
static inline SString FromFloat(const float &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline long ToLong(const SString &str)
@@ -186,7 +178,7 @@ public:
static inline SString FromLong(const long &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static inline double ToDouble(const SString &str)
@@ -196,7 +188,7 @@ public:
static inline SString FromDouble(const double &value)
{
return SString(std::to_string(value));
return std::move(SString(std::to_string(value)));
}
static bool ToBool(const SString& value)
@@ -221,7 +213,7 @@ public:
{
ret.push_back(&s[0]);
}
return ret;
return std::move(ret);
}
#ifdef _UNICODE
@@ -232,7 +224,7 @@ public:
{
ret.push_back(ToUtf8(s.str()));
}
return ret;
return std::move(ret);
}
#else
static std::vector<std::string> ToUtf8Array(const SStringVector& v)
@@ -242,7 +234,7 @@ public:
{
ret.push_back(s.str());
}
return ret;
return std::move(ret);
}
#endif
@@ -253,7 +245,7 @@ public:
SString(const std::string &str) :
#ifdef _UNICODE
_str(SString::FromUtf8(str))
_str(std::move(SString::FromUtf8(str)))
#else
_str(str)
#endif
@@ -262,7 +254,7 @@ public:
SString(const char *str) :
#ifdef _UNICODE
_str(SString::FromUtf8(str))
_str(std::move(SString::FromUtf8(str)))
#else
_str(str)
#endif
@@ -273,7 +265,7 @@ public:
#ifdef _UNICODE
_str(str)
#else
_str(SString::ToUtf8(str))
_str(std::move(SString::ToUtf8(str)))
#endif
{
}
@@ -282,7 +274,7 @@ public:
#ifdef _UNICODE
_str(str)
#else
_str(SString::ToUtf8(str))
_str(std::move(SString::ToUtf8(str)))
#endif
{
}
@@ -375,7 +367,7 @@ public:
{
String str = _str;
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
return str;
return std::move(str);
}
SString &ToUpper()
@@ -388,7 +380,7 @@ public:
{
String str = _str;
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
return str;
return std::move(str);
}
bool IsEmpty() const
@@ -463,7 +455,7 @@ public:
SString ReplaceCopy(const char &character, const char &with) const
{
SString copy = _str;
return copy.Replace((SChar) character, (SChar) with);
return std::move(copy.Replace((SChar) character, (SChar) with));
}
#endif
@@ -471,7 +463,7 @@ public:
SString ReplaceCopy(const SChar &character, const SChar &with) const
{
SString copy = _str;
return copy.Replace(character, with);
return std::move(copy.Replace(character, with));
}
SString& Replace(const SString& str, const SString& with, size_t startPos = 0)
@@ -490,7 +482,7 @@ public:
SString ReplaceCopy(const SString& str, const SString& with, size_t startPos = 0) const
{
return SString(_str).Replace(str, with, startPos);
return std::move(SString(_str).Replace(str, with, startPos));
}
inline void Resize(const String::size_type& size)
@@ -516,7 +508,7 @@ public:
elems.push_back(trim ? Trim(item) : item);
}
return elems;
return std::move(elems);
}
SString& TrimLeft()
@@ -528,7 +520,7 @@ public:
SString TrimLeftCopy() const
{
String copy(_str);
return LeftTrim(copy);
return std::move(LeftTrim(copy));
}
SString& TrimRight()
@@ -540,7 +532,7 @@ public:
SString TrimRightCopy() const
{
String copy(_str);
return RightTrim(copy);
return std::move(RightTrim(copy));
}
SString& Trim()
@@ -552,7 +544,7 @@ public:
SString TrimCopy() const
{
String copy(_str);
return Trim(copy);
return std::move(Trim(copy));
}
SString SubString(const size_t &start, const size_t &count) const
@@ -670,7 +662,7 @@ public:
operator std::string() const
{
#ifdef _UNICODE
return SString::ToUtf8(_str);
return std::move(SString::ToUtf8(_str));
#else
return _str;
#endif
@@ -681,7 +673,7 @@ public:
#ifdef _UNICODE
return _str;
#else
return SString::FromUtf8(_str);
return std::move(SString::FromUtf8(_str));
#endif
}