#include "pip.h"
#include "piiostream.h"
#include "pibytearray.h"
#include "pimathbase.h"
#include "pijson.h"
#include "pivaluetree.h"

using namespace PICoutManipulators;

struct SomeType {
	int i;
	float f;
};

PICout operator <<(PICout c, const SomeType & v) {
	c << "SomeType(" << v.i << "," << v.f << ")";
	return c;
}

REGISTER_VARIANT(SomeType);
REGISTER_VARIANT_CAST(SomeType, PIString) {
	return PIString::fromNumber(v.i) + ";" + PIString::fromNumber(v.f);
}
REGISTER_VARIANT_CAST(PIString, SomeType) {
	PIStringList sl = v.split(';').resize(2);
	return SomeType{sl[0].toInt(), sl[1].toFloat()};
}

int main(int argc, char * argv[]) {
	/*PIValueTree root;
	root.addChild({"bool", PIVariant(false)});
	root.addChild({"integer", PIVariant(256)});
	root.addChild({"string", PIVariant("str")});
	for (auto it: root.children()) {
		piCout << it.name() << it.value();
	}
	piCout << piSerialize(root);*/
	//PIVariant v = PIVariant::fromType(PIVariant::typeID<double>());
	//piCout << v;
	//piCout << v.toString();
	//v.setValueFromString("2E-3");
	//piCout << v.value<double>();
	//piCout << v.toString();

	//piCout << PITime();
	//piCout << PITime::fromString("05:12:56");
	//piCout << PITime::fromString("05: 12:56");
	//piCout << PITime::fromString("05.12:56");
	//piCout << PITime::fromString("05.12:56:333", "h.m.s");
	//piCout << PIDateTime::fromString(PIDateTime::current().toString("__yyyy_MM_d__hh_mm_ss__"), "__yyyy_MM_d__hh_mm_ss__");

	/*piCout << PIVariantTypes::Color();
	piCout << PIVariantTypes::Color(0xFF00FFff);
	PIVariant v = PIVariant::fromType(PIVariant::typeName<PIVariantTypes::Color>());
	piCout << PIVariant::typeName<PIPointd>();
	piCout << PIVariant::typeFromName(PIVariant::typeName<PIVariantTypes::Color>());
	piCout << PIVariant::typeIDFromName(PIVariant::typeName<PIVariantTypes::Color>());
	piCout << PIVariant::typeIDFromType(PIVariant::pivColor);
	v.setValueFromString("0xFF00FFff");
	piCout << v;*/

	PIString ms = "1239";

	piCout << PIString("12\\\\3456789").masked(ms);
	piCout << PIString("12\\\\3456789").masked(ms).unmasked(ms);

	return 0;
}
