Example #1
0
/**
 * Saves the target's unique identifiers to a YAML file.
 * @return YAML node.
 */
YAML::Node Target::saveId() const
{
	YAML::Node node;
	node["lon"] = serializeDouble(_lon);
	node["lat"] = serializeDouble(_lat);
	return node;
}
Example #2
0
/**
 * Saves the target to a YAML file.
 * @returns YAML node.
 */
YAML::Node Target::save() const
{
	YAML::Node node;
	node["lon"] = serializeDouble(_lon);
	node["lat"] = serializeDouble(_lat);
	if (_depth)
		node["depth"] = _depth;
	return node;
}
Example #3
0
/**
 * Saves the moving target to a YAML file.
 * @return YAML node.
 */
YAML::Node MovingTarget::save() const
{
	YAML::Node node = Target::save();
	if (_dest != 0)
	{
		node["dest"] = _dest->saveId();
	}
	node["speedLon"] = serializeDouble(_speedLon);
	node["speedLat"] = serializeDouble(_speedLat);
	node["speedRadian"] = serializeDouble(_speedRadian);
	node["speed"] = _speed;
	return node;
}
Example #4
0
 QString Serializer::serialize(QVariant v, int indent, bool parentIsArray) {
   if (!v.isValid())
     return QString(); // invalid
   if (v.type()==QVariant::List) 
     return serializeList(v.toList(), indent, parentIsArray);
   else if (v.type()==QVariant::Map)
     return serializeMap(v.toMap(), indent, parentIsArray);
   else if (v.type()==QVariant::String || v.type()==QVariant::ByteArray)
     return serializeString(v.toString());
   else if (v.type()==QVariant::Double)
     return serializeDouble(v.toDouble());
   else if (v.type()==QVariant::Bool)
     return v.toBool() ? "true" : "false";
   else if (v.type() == QVariant::ULongLong )
     return QString::number(v.value<qulonglong>());
   else if (v.canConvert<qlonglong>())
     return QString::number(v.value<qlonglong>());
   else if (v.canConvert<QString>())
     // this will catch QDate, QDateTime, QUrl, ...
     return serializeString(v.toString());
   else
     return QString();
 }