Exemple #1
0
size_t hash_value(const VarValue& v) {
	switch (v.type()) {
	case VarType::Null:		return 0;
	case VarType::Int:		return hash<Int64>()(v.ToInt64());
	case VarType::Float:	return hash<double>()(v.ToDouble());
	case VarType::Bool:		return hash<bool>()(v.ToBool());
	case VarType::String:	return hash<String>()(v.ToString());
	case VarType::Array:
		{
			size_t r = 0;
			for (int i=0; i<v.size(); ++i)
				r += hash<VarValue>()(v[i]);
			return r;
		}
	case VarType::Map:
		{
			vector<String> keys = v.Keys();
			size_t r = 0;
			for (int i=0; i<keys.size(); ++i)
				r += hash<VarValue>()(v[keys[i]]);
			return r;
		}
	default:
		Throw(E_NOTIMPL);
	}
}
Exemple #2
0
	void ProcessSubmitResult(const VarValue& v) {
		switch (v.type()) {
		case VarType::Null:
			break;
		case VarType::String:
			{
				String rej = v.ToString();
				throw system_error(SubmitRejectionCode(rej), coin_category(), rej);
			}
		case VarType::Map:
			throw system_error(SubmitRejectionCode("rejected"), coin_category(), String::Join(", ", v.Keys()));
		default:
			Throw(errc::invalid_argument);
		}
	}