Exemplo n.º 1
0
bool DynamicAny::operator != (const DynamicAny& other) const
{
	if (isEmpty() && other.isEmpty()) return false;
	else if (isEmpty() || other.isEmpty()) return true;

	return convert<std::string>() != other.convert<std::string>();
}
Exemplo n.º 2
0
void doUDT()
{
	SSN udt1(123456789);
	DynamicAny da = udt1;
	std::string ssn = da.toString();
	int i = da;
	std::cout << ssn << std::endl;
	SSN udt2 = da;
	std::cout << udt2.nSSN() << std::endl;
}
Exemplo n.º 3
0
void AbstractBinder::bind(std::size_t pos, const DynamicAny& val, Direction dir)
{
	const std::type_info& type = val.type();

	if(type == typeid(Int32))
		bind(pos, val.extract<Int32>(), dir);
	else if(type == typeid(std::string))
		bind(pos, val.extract<std::string>(), dir);
	else if (type == typeid(bool))
		bind(pos, val.extract<bool>(), dir);
	else if(type == typeid(char))
		bind(pos, val.extract<char>(), dir);
	else if(type == typeid(Int8))
		bind(pos, val.extract<Int8>(), dir);
	else if(type == typeid(UInt8))
		bind(pos, val.extract<UInt8>(), dir);
	else if(type == typeid(Int16))
		bind(pos, val.extract<Int16>(), dir);
	else if(type == typeid(UInt16))
		bind(pos, val.extract<UInt16>(), dir);
	else if(type == typeid(UInt32))
		bind(pos, val.extract<UInt32>(), dir);
	else if(type == typeid(Int64))
		bind(pos, val.extract<Int64>(), dir);
	else if(type == typeid(UInt64))
		bind(pos, val.extract<UInt64>(), dir);
	else if(type == typeid(float))
		bind(pos, val.extract<float>(), dir);
	else if(type == typeid(double))
		bind(pos, val.extract<double>(), dir);
	else if(type == typeid(DateTime))
		bind(pos, val.extract<DateTime>(), dir);
	else if(type == typeid(Date))
		bind(pos, val.extract<Date>(), dir);
	else if(type == typeid(Time))
		bind(pos, val.extract<Time>(), dir);
	else if(type == typeid(BLOB))
		bind(pos, val.extract<BLOB>(), dir);
#ifndef POCO_LONG_IS_64_BIT
	else if(type == typeid(long))
		bind(pos, val.extract<long>(), dir);
#endif
	else
		throw UnknownTypeException(std::string(val.type().name()));
}
Exemplo n.º 4
0
bool DynamicAny::operator && (const DynamicAny& other) const
{
	if (isEmpty() || other.isEmpty()) return false;
	return convert<bool>() && other.convert<bool>();
}
Exemplo n.º 5
0
bool DynamicAny::operator >= (const DynamicAny& other) const
{
	if (isEmpty() || other.isEmpty()) return false;
	return convert<std::string>() >= other.convert<std::string>();
}
Exemplo n.º 6
0
void Stringifier::stringify(const DynamicAny& any, std::ostream& out, unsigned int indent)
{
	if ( any.type() == typeid(Object::Ptr) )
	{
		const Object::Ptr& o = any.extract<Object::Ptr>();
		o->stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.type() == typeid(Array::Ptr) )
	{
		const Array::Ptr& a = any.extract<Array::Ptr>();
		a->stringify(out, indent == 0 ? 0 : indent + 2);
	}
	else if ( any.isEmpty() )
	{
		out << "null";
	}
	else if ( any.isString() )
	{
		out << '"';
		std::string value = any.convert<std::string>();
		for(std::string::const_iterator it = value.begin(); it != value.end(); ++it)
		{
			switch (*it)
			{
			case '"':
				out << "\\\"";
				break;
			case '\\':
				out << "\\\\";
				break;
			case '\b':
				out << "\\b";
				break;
			case '\f':
				out << "\\f";
				break;
			case '\n':
				out << "\\n";
				break;
			case '\r':
				out << "\\r";
				break;
			case '\t':
				out << "\\t";
				break;
			default:
			{
				if ( *it > 0 && *it <= 0x1F )
				{
					out << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*it);
				}
				else
				{
					out << *it;
				}
				break;
			}
			}
		}
		out << '"';
	}
	else
	{
		out << any.convert<std::string>();
	}
}