]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props.cxx
MacOS X fix
[simgear.git] / simgear / props / props.cxx
index 042275e4ce9d14f607bc1146f8c06ec8f1da0efa..0bc56dcd6fd786241e9b9b57468e95b23e3338af 100644 (file)
@@ -6,6 +6,10 @@
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
 #include "props.hxx"
 
 #include <algorithm>
@@ -15,6 +19,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <simgear/math/SGMath.hxx>
+
 #if PROPS_STANDALONE
 #include <iostream>
 #else
@@ -41,7 +47,6 @@ using std::vector;
 using std::stringstream;
 
 using namespace simgear;
-using namespace simgear::props;
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -68,17 +73,7 @@ public:
 #define TEST_READ(dflt) if (!getAttribute(READ)) return dflt
 #define TEST_WRITE if (!getAttribute(WRITE)) return false
 \f
-////////////////////////////////////////////////////////////////////////
-// Default values for every type.
-////////////////////////////////////////////////////////////////////////
 
-template<> const bool SGRawValue<bool>::DefaultValue = false;
-template<> const int SGRawValue<int>::DefaultValue = 0;
-template<> const long SGRawValue<long>::DefaultValue = 0L;
-template<> const float SGRawValue<float>::DefaultValue = 0.0;
-template<> const double SGRawValue<double>::DefaultValue = 0.0L;
-template<> const char * const SGRawValue<const char *>::DefaultValue = "";
-\f
 ////////////////////////////////////////////////////////////////////////
 // Local path normalization code.
 ////////////////////////////////////////////////////////////////////////
@@ -248,7 +243,7 @@ compare_strings (const char * s1, const char * s2)
  * Locate a child node by name and index.
  */
 static int
-find_child (const char * name, int index, const vector<SGPropertyNode_ptr>& nodes)
+find_child (const char * name, int index, const PropertyList& nodes)
 {
   int nNodes = nodes.size();
   for (int i = 0; i < nNodes; i++) {
@@ -266,7 +261,7 @@ find_child (const char * name, int index, const vector<SGPropertyNode_ptr>& node
  * Locate the child node with the highest index of the same name
  */
 static int
-find_last_child (const char * name, const vector<SGPropertyNode_ptr>& nodes)
+find_last_child (const char * name, const PropertyList& nodes)
 {
   int nNodes = nodes.size();
   int index = 0;
@@ -497,39 +492,41 @@ SGPropertyNode::set_string (const char * val)
 void
 SGPropertyNode::clearValue ()
 {
-    if (_type == ALIAS) {
+    if (_type == props::ALIAS) {
         put(_value.alias);
         _value.alias = 0;
-    } else if (_type != NONE) {
+    } else if (_type != props::NONE) {
         switch (_type) {
-        case BOOL:
-            _local_val.bool_val = SGRawValue<bool>::DefaultValue;
+        case props::BOOL:
+            _local_val.bool_val = SGRawValue<bool>::DefaultValue();
             break;
-        case INT:
-            _local_val.int_val = SGRawValue<int>::DefaultValue;
+        case props::INT:
+            _local_val.int_val = SGRawValue<int>::DefaultValue();
             break;
-        case LONG:
-            _local_val.long_val = SGRawValue<long>::DefaultValue;
+        case props::LONG:
+            _local_val.long_val = SGRawValue<long>::DefaultValue();
             break;
-        case FLOAT:
-            _local_val.float_val = SGRawValue<float>::DefaultValue;
+        case props::FLOAT:
+            _local_val.float_val = SGRawValue<float>::DefaultValue();
             break;
-        case DOUBLE:
-            _local_val.double_val = SGRawValue<double>::DefaultValue;
+        case props::DOUBLE:
+            _local_val.double_val = SGRawValue<double>::DefaultValue();
             break;
-        case STRING:
-        case UNSPECIFIED:
+        case props::STRING:
+        case props::UNSPECIFIED:
             if (!_tied) {
                 delete [] _local_val.string_val;
             }
             _local_val.string_val = 0;
             break;
+        default: // avoid compiler warning
+            break;
         }
         delete _value.val;
         _value.val = 0;
     }
     _tied = false;
-    _type = NONE;
+    _type = props::NONE;
 }
 
 
@@ -542,34 +539,40 @@ SGPropertyNode::make_string () const
     if (!getAttribute(READ))
         return "";
     switch (_type) {
-    case ALIAS:
+    case props::ALIAS:
         return _value.alias->getStringValue();
-    case BOOL:
+    case props::BOOL:
         return get_bool() ? "true" : "false";
-    case STRING:
-    case UNSPECIFIED:
+    case props::STRING:
+    case props::UNSPECIFIED:
         return get_string();
-    case NONE:
+    case props::NONE:
         return "";
     default:
         break;
     }
     stringstream sstr;
     switch (_type) {
-    case INT:
+    case props::INT:
         sstr << get_int();
         break;
-    case LONG:
+    case props::LONG:
         sstr << get_long();
         break;
-    case FLOAT:
+    case props::FLOAT:
         sstr << get_float();
         break;
-    case DOUBLE:
+    case props::DOUBLE:
         sstr << std::setprecision(10) << get_double();
         break;
-    case EXTENDED:
+    case props::EXTENDED:
+    {
+        props::Type realType = _value.val->getType();
+        // Perhaps this should be done for all types?
+        if (realType == props::VEC3D || realType == props::VEC4D)
+            sstr.precision(10);
         static_cast<SGRawExtended*>(_value.val)->printOn(sstr);
+    }
         break;
     default:
         return "";
@@ -626,7 +629,7 @@ SGPropertyNode::SGPropertyNode ()
   : _index(0),
     _parent(0),
     _path_cache(0),
-    _type(NONE),
+    _type(props::NONE),
     _tied(false),
     _attr(READ|WRITE),
     _listeners(0)
@@ -651,36 +654,36 @@ SGPropertyNode::SGPropertyNode (const SGPropertyNode &node)
 {
   _local_val.string_val = 0;
   _value.val = 0;
-  if (_type == NONE)
+  if (_type == props::NONE)
     return;
-  if (_type == ALIAS) {
+  if (_type == props::ALIAS) {
     _value.alias = node._value.alias;
     get(_value.alias);
     _tied = false;
     return;
   }
-  if (_tied || _type == EXTENDED) {
+  if (_tied || _type == props::EXTENDED) {
     _value.val = node._value.val->clone();
     return;
   }
   switch (_type) {
-  case BOOL:
+  case props::BOOL:
     set_bool(node.get_bool());    
     break;
-  case INT:
+  case props::INT:
     set_int(node.get_int());
     break;
-  case LONG:
+  case props::LONG:
     set_long(node.get_long());
     break;
-  case FLOAT:
+  case props::FLOAT:
     set_float(node.get_float());
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     set_double(node.get_double());
     break;
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     set_string(node.get_string());
     break;
   default:
@@ -698,7 +701,7 @@ SGPropertyNode::SGPropertyNode (const char * name,
   : _index(index),
     _parent(parent),
     _path_cache(0),
-    _type(NONE),
+    _type(props::NONE),
     _tied(false),
     _attr(READ|WRITE),
     _listeners(0)
@@ -740,12 +743,12 @@ SGPropertyNode::~SGPropertyNode ()
 bool
 SGPropertyNode::alias (SGPropertyNode * target)
 {
-  if (target == 0 || _type == ALIAS || _tied)
+  if (target == 0 || _type == props::ALIAS || _tied)
     return false;
   clearValue();
   get(target);
   _value.alias = target;
-  _type = ALIAS;
+  _type = props::ALIAS;
   return true;
 }
 
@@ -766,7 +769,7 @@ SGPropertyNode::alias (const char * path)
 bool
 SGPropertyNode::unalias ()
 {
-  if (_type != ALIAS)
+  if (_type != props::ALIAS)
     return false;
   clearValue();
   return true;
@@ -779,14 +782,14 @@ SGPropertyNode::unalias ()
 SGPropertyNode *
 SGPropertyNode::getAliasTarget ()
 {
-  return (_type == ALIAS ? _value.alias : 0);
+  return (_type == props::ALIAS ? _value.alias : 0);
 }
 
 
 const SGPropertyNode *
 SGPropertyNode::getAliasTarget () const
 {
-  return (_type == ALIAS ? _value.alias : 0);
+  return (_type == props::ALIAS ? _value.alias : 0);
 }
 
 /**
@@ -844,7 +847,7 @@ SGPropertyNode::getChild (const char * name, int index, bool create)
     SGPropertyNode_ptr node;
     pos = find_child(name, index, _removedChildren);
     if (pos >= 0) {
-      vector<SGPropertyNode_ptr>::iterator it = _removedChildren.begin();
+      PropertyList::iterator it = _removedChildren.begin();
       it += pos;
       node = _removedChildren[pos];
       _removedChildren.erase(it);
@@ -878,10 +881,10 @@ SGPropertyNode::getChild (const char * name, int index) const
 /**
  * Get all children with the same name (but different indices).
  */
-vector<SGPropertyNode_ptr>
+PropertyList
 SGPropertyNode::getChildren (const char * name) const
 {
-  vector<SGPropertyNode_ptr> children;
+  PropertyList children;
   int max = _children.size();
 
   for (int i = 0; i < max; i++)
@@ -919,7 +922,7 @@ SGPropertyNode::removeChild (int pos, bool keep)
   if (pos < 0 || pos >= (int)_children.size())
     return node;
 
-  vector<SGPropertyNode_ptr>::iterator it = _children.begin();
+  PropertyList::iterator it = _children.begin();
   it += pos;
   node = _children[pos];
   _children.erase(it);
@@ -952,10 +955,10 @@ SGPropertyNode::removeChild (const char * name, int index, bool keep)
 /**
   * Remove all children with the specified name.
   */
-vector<SGPropertyNode_ptr>
+PropertyList
 SGPropertyNode::removeChildren (const char * name, bool keep)
 {
-  vector<SGPropertyNode_ptr> children;
+  PropertyList children;
 
   for (int pos = _children.size() - 1; pos >= 0; pos--)
     if (compare_strings(_children[pos]->getName(), name))
@@ -984,16 +987,16 @@ SGPropertyNode::remove_linked_node (hash_table * node)
 }
 
 
-const char *
+string
 SGPropertyNode::getDisplayName (bool simplify) const
 {
-  _display_name = _name;
+  string display_name = _name;
   if (_index != 0 || !simplify) {
     stringstream sstr;
     sstr << '[' << _index << ']';
-    _display_name += sstr.str();
+    display_name += sstr.str();
   }
-  return _display_name.c_str();
+  return display_name;
 }
 
 
@@ -1010,12 +1013,12 @@ SGPropertyNode::getPath (bool simplify) const
   return _path.c_str();
 }
 
-Type
+props::Type
 SGPropertyNode::getType () const
 {
-  if (_type == ALIAS)
+  if (_type == props::ALIAS)
     return _value.alias->getType();
-  else if (_type == EXTENDED)
+  else if (_type == props::EXTENDED)
       return _value.val->getType();
   else
     return _type;
@@ -1026,32 +1029,32 @@ bool
 SGPropertyNode::getBoolValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == BOOL)
+  if (_attr == (READ|WRITE) && _type == props::BOOL)
     return get_bool();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<bool>::DefaultValue;
+    return SGRawValue<bool>::DefaultValue();
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     return _value.alias->getBoolValue();
-  case BOOL:
+  case props::BOOL:
     return get_bool();
-  case INT:
+  case props::INT:
     return get_int() == 0 ? false : true;
-  case LONG:
+  case props::LONG:
     return get_long() == 0L ? false : true;
-  case FLOAT:
+  case props::FLOAT:
     return get_float() == 0.0 ? false : true;
-  case DOUBLE:
+  case props::DOUBLE:
     return get_double() == 0.0L ? false : true;
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     return (compare_strings(get_string(), "true") || getDoubleValue() != 0.0L);
-  case NONE:
+  case props::NONE:
   default:
-    return SGRawValue<bool>::DefaultValue;
+    return SGRawValue<bool>::DefaultValue();
   }
 }
 
@@ -1059,32 +1062,32 @@ int
 SGPropertyNode::getIntValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == INT)
+  if (_attr == (READ|WRITE) && _type == props::INT)
     return get_int();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<int>::DefaultValue;
+    return SGRawValue<int>::DefaultValue();
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     return _value.alias->getIntValue();
-  case BOOL:
+  case props::BOOL:
     return int(get_bool());
-  case INT:
+  case props::INT:
     return get_int();
-  case LONG:
+  case props::LONG:
     return int(get_long());
-  case FLOAT:
+  case props::FLOAT:
     return int(get_float());
-  case DOUBLE:
+  case props::DOUBLE:
     return int(get_double());
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     return atoi(get_string());
-  case NONE:
+  case props::NONE:
   default:
-    return SGRawValue<int>::DefaultValue;
+    return SGRawValue<int>::DefaultValue();
   }
 }
 
@@ -1092,32 +1095,32 @@ long
 SGPropertyNode::getLongValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == LONG)
+  if (_attr == (READ|WRITE) && _type == props::LONG)
     return get_long();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<long>::DefaultValue;
+    return SGRawValue<long>::DefaultValue();
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     return _value.alias->getLongValue();
-  case BOOL:
+  case props::BOOL:
     return long(get_bool());
-  case INT:
+  case props::INT:
     return long(get_int());
-  case LONG:
+  case props::LONG:
     return get_long();
-  case FLOAT:
+  case props::FLOAT:
     return long(get_float());
-  case DOUBLE:
+  case props::DOUBLE:
     return long(get_double());
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     return strtol(get_string(), 0, 0);
-  case NONE:
+  case props::NONE:
   default:
-    return SGRawValue<long>::DefaultValue;
+    return SGRawValue<long>::DefaultValue();
   }
 }
 
@@ -1125,32 +1128,32 @@ float
 SGPropertyNode::getFloatValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == FLOAT)
+  if (_attr == (READ|WRITE) && _type == props::FLOAT)
     return get_float();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<float>::DefaultValue;
+    return SGRawValue<float>::DefaultValue();
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     return _value.alias->getFloatValue();
-  case BOOL:
+  case props::BOOL:
     return float(get_bool());
-  case INT:
+  case props::INT:
     return float(get_int());
-  case LONG:
+  case props::LONG:
     return float(get_long());
-  case FLOAT:
+  case props::FLOAT:
     return get_float();
-  case DOUBLE:
+  case props::DOUBLE:
     return float(get_double());
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     return atof(get_string());
-  case NONE:
+  case props::NONE:
   default:
-    return SGRawValue<float>::DefaultValue;
+    return SGRawValue<float>::DefaultValue();
   }
 }
 
@@ -1158,33 +1161,33 @@ double
 SGPropertyNode::getDoubleValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == DOUBLE)
+  if (_attr == (READ|WRITE) && _type == props::DOUBLE)
     return get_double();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<double>::DefaultValue;
+    return SGRawValue<double>::DefaultValue();
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     return _value.alias->getDoubleValue();
-  case BOOL:
+  case props::BOOL:
     return double(get_bool());
-  case INT:
+  case props::INT:
     return double(get_int());
-  case LONG:
+  case props::LONG:
     return double(get_long());
-  case FLOAT:
+  case props::FLOAT:
     return double(get_float());
-  case DOUBLE:
+  case props::DOUBLE:
     return get_double();
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     return strtod(get_string(), 0);
-  case NONE:
+  case props::NONE:
   default:
-    return SGRawValue<double>::DefaultValue;
+    return SGRawValue<double>::DefaultValue();
   }
 }
 
@@ -1192,13 +1195,13 @@ const char *
 SGPropertyNode::getStringValue () const
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == STRING)
+  if (_attr == (READ|WRITE) && _type == props::STRING)
     return get_string();
 
   if (getAttribute(TRACE_READ))
     trace_read();
   if (!getAttribute(READ))
-    return SGRawValue<const char *>::DefaultValue;
+    return SGRawValue<const char *>::DefaultValue();
   return make_string();
 }
 
@@ -1206,41 +1209,41 @@ bool
 SGPropertyNode::setBoolValue (bool value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == BOOL)
+  if (_attr == (READ|WRITE) && _type == props::BOOL)
     return set_bool(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
     _tied = false;
-    _type = BOOL;
+    _type = props::BOOL;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setBoolValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool(value);
     break;
-  case INT:
+  case props::INT:
     result = set_int(int(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(long(value));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(float(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(double(value));
     break;
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     result = set_string(value ? "true" : "false");
     break;
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1254,44 +1257,44 @@ bool
 SGPropertyNode::setIntValue (int value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == INT)
+  if (_attr == (READ|WRITE) && _type == props::INT)
     return set_int(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
-    _type = INT;
+    _type = props::INT;
     _local_val.int_val = 0;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setIntValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool(value == 0 ? false : true);
     break;
-  case INT:
+  case props::INT:
     result = set_int(value);
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(long(value));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(float(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(double(value));
     break;
-  case STRING:
-  case UNSPECIFIED: {
+  case props::STRING:
+  case props::UNSPECIFIED: {
     char buf[128];
     sprintf(buf, "%d", value);
     result = set_string(buf);
     break;
   }
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1305,44 +1308,44 @@ bool
 SGPropertyNode::setLongValue (long value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == LONG)
+  if (_attr == (READ|WRITE) && _type == props::LONG)
     return set_long(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
-    _type = LONG;
+    _type = props::LONG;
     _local_val.long_val = 0L;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setLongValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool(value == 0L ? false : true);
     break;
-  case INT:
+  case props::INT:
     result = set_int(int(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(value);
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(float(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(double(value));
     break;
-  case STRING:
-  case UNSPECIFIED: {
+  case props::STRING:
+  case props::UNSPECIFIED: {
     char buf[128];
     sprintf(buf, "%ld", value);
     result = set_string(buf);
     break;
   }
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1356,44 +1359,44 @@ bool
 SGPropertyNode::setFloatValue (float value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == FLOAT)
+  if (_attr == (READ|WRITE) && _type == props::FLOAT)
     return set_float(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
-    _type = FLOAT;
+    _type = props::FLOAT;
     _local_val.float_val = 0;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setFloatValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool(value == 0.0 ? false : true);
     break;
-  case INT:
+  case props::INT:
     result = set_int(int(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(long(value));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(value);
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(double(value));
     break;
-  case STRING:
-  case UNSPECIFIED: {
+  case props::STRING:
+  case props::UNSPECIFIED: {
     char buf[128];
     sprintf(buf, "%f", value);
     result = set_string(buf);
     break;
   }
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1407,44 +1410,44 @@ bool
 SGPropertyNode::setDoubleValue (double value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == DOUBLE)
+  if (_attr == (READ|WRITE) && _type == props::DOUBLE)
     return set_double(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
     _local_val.double_val = value;
-    _type = DOUBLE;
+    _type = props::DOUBLE;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setDoubleValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool(value == 0.0L ? false : true);
     break;
-  case INT:
+  case props::INT:
     result = set_int(int(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(long(value));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(float(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(value);
     break;
-  case STRING:
-  case UNSPECIFIED: {
+  case props::STRING:
+  case props::UNSPECIFIED: {
     char buf[128];
     sprintf(buf, "%f", value);
     result = set_string(buf);
     break;
   }
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1458,47 +1461,47 @@ bool
 SGPropertyNode::setStringValue (const char * value)
 {
                                // Shortcut for common case
-  if (_attr == (READ|WRITE) && _type == STRING)
+  if (_attr == (READ|WRITE) && _type == props::STRING)
     return set_string(value);
 
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE || _type == UNSPECIFIED) {
+  if (_type == props::NONE || _type == props::UNSPECIFIED) {
     clearValue();
-    _type = STRING;
+    _type = props::STRING;
   }
 
   switch (_type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setStringValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool((compare_strings(value, "true")
                       || atoi(value)) ? true : false);
     break;
-  case INT:
+  case props::INT:
     result = set_int(atoi(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(strtol(value, 0, 0));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(atof(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(strtod(value, 0));
     break;
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     result = set_string(value);
     break;
-  case EXTENDED:
+  case props::EXTENDED:
   {
     stringstream sstr(value);
     static_cast<SGRawExtended*>(_value.val)->readFrom(sstr);
   }
   break;
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1513,38 +1516,44 @@ SGPropertyNode::setUnspecifiedValue (const char * value)
 {
   bool result = false;
   TEST_WRITE;
-  if (_type == NONE) {
+  if (_type == props::NONE) {
     clearValue();
-    _type = UNSPECIFIED;
+    _type = props::UNSPECIFIED;
   }
-  Type type = _type;
-  if (type == EXTENDED)
+  props::Type type = _type;
+  if (type == props::EXTENDED)
       type = _value.val->getType();
   switch (type) {
-  case ALIAS:
+  case props::ALIAS:
     result = _value.alias->setUnspecifiedValue(value);
     break;
-  case BOOL:
+  case props::BOOL:
     result = set_bool((compare_strings(value, "true")
                       || atoi(value)) ? true : false);
     break;
-  case INT:
+  case props::INT:
     result = set_int(atoi(value));
     break;
-  case LONG:
+  case props::LONG:
     result = set_long(strtol(value, 0, 0));
     break;
-  case FLOAT:
+  case props::FLOAT:
     result = set_float(atof(value));
     break;
-  case DOUBLE:
+  case props::DOUBLE:
     result = set_double(strtod(value, 0));
     break;
-  case STRING:
-  case UNSPECIFIED:
+  case props::STRING:
+  case props::UNSPECIFIED:
     result = set_string(value);
     break;
-  case NONE:
+  case props::VEC3D:
+      result = static_cast<SGRawValue<SGVec3d>*>(_value.val)->setValue(parseString<SGVec3d>(value));
+      break;
+  case props::VEC4D:
+      result = static_cast<SGRawValue<SGVec4d>*>(_value.val)->setValue(parseString<SGVec4d>(value));
+      break;
+  case props::NONE:
   default:
     break;
   }
@@ -1559,31 +1568,33 @@ std::ostream& SGPropertyNode::printOn(std::ostream& stream) const
     if (!getAttribute(READ))
         return stream;
     switch (_type) {
-    case ALIAS:
+    case props::ALIAS:
         return _value.alias->printOn(stream);
-    case BOOL:
+    case props::BOOL:
         stream << (get_bool() ? "true" : "false");
         break;
-    case INT:
+    case props::INT:
         stream << get_int();
         break;
-    case LONG:
+    case props::LONG:
         stream << get_long();
         break;
-    case FLOAT:
+    case props::FLOAT:
         stream << get_float();
         break;
-    case DOUBLE:
+    case props::DOUBLE:
         stream << get_double();
         break;
-    case STRING:
-    case UNSPECIFIED:
+    case props::STRING:
+    case props::UNSPECIFIED:
         stream << get_string();
         break;
-    case EXTENDED:
+    case props::EXTENDED:
         static_cast<SGRawExtended*>(_value.val)->printOn(stream);
         break;
-    case NONE:
+    case props::NONE:
+        break;
+    default: // avoid compiler warning
         break;
     }
     return stream;
@@ -1593,7 +1604,7 @@ template<>
 bool SGPropertyNode::tie (const SGRawValue<const char *> &rawValue,
                           bool useDefault)
 {
-    if (_type == ALIAS || _tied)
+    if (_type == props::ALIAS || _tied)
         return false;
 
     useDefault = useDefault && hasValue();
@@ -1601,7 +1612,7 @@ bool SGPropertyNode::tie (const SGRawValue<const char *> &rawValue,
     if (useDefault)
         old_val = getStringValue();
     clearValue();
-    _type = STRING;
+    _type = props::STRING;
     _tied = true;
     _value.val = rawValue.clone();
 
@@ -1617,59 +1628,59 @@ SGPropertyNode::untie ()
     return false;
 
   switch (_type) {
-  case BOOL: {
+  case props::BOOL: {
     bool val = getBoolValue();
     clearValue();
-    _type = BOOL;
+    _type = props::BOOL;
     _local_val.bool_val = val;
     break;
   }
-  case INT: {
+  case props::INT: {
     int val = getIntValue();
     clearValue();
-    _type = INT;
+    _type = props::INT;
     _local_val.int_val = val;
     break;
   }
-  case LONG: {
+  case props::LONG: {
     long val = getLongValue();
     clearValue();
-    _type = LONG;
+    _type = props::LONG;
     _local_val.long_val = val;
     break;
   }
-  case FLOAT: {
+  case props::FLOAT: {
     float val = getFloatValue();
     clearValue();
-    _type = FLOAT;
+    _type = props::FLOAT;
     _local_val.float_val = val;
     break;
   }
-  case DOUBLE: {
+  case props::DOUBLE: {
     double val = getDoubleValue();
     clearValue();
-    _type = DOUBLE;
+    _type = props::DOUBLE;
     _local_val.double_val = val;
     break;
   }
-  case STRING:
-  case UNSPECIFIED: {
+  case props::STRING:
+  case props::UNSPECIFIED: {
     string val = getStringValue();
     clearValue();
-    _type = STRING;
+    _type = props::STRING;
     _local_val.string_val = copy_string(val.c_str());
     break;
   }
-  case EXTENDED: {
+  case props::EXTENDED: {
     SGRawExtended* val = static_cast<SGRawExtended*>(_value.val);
     _value.val = 0;             // Prevent clearValue() from deleting
     clearValue();
-    _type = EXTENDED;
+    _type = props::EXTENDED;
     _value.val = val->makeContainer();
     delete val;
     break;
   }
-  case NONE:
+  case props::NONE:
   default:
     break;
   }
@@ -1756,11 +1767,11 @@ SGPropertyNode::hasValue (const char * relative_path) const
 /**
  * Get the value type for another node.
  */
-Type
+props::Type
 SGPropertyNode::getType (const char * relative_path) const
 {
   const SGPropertyNode * node = getNode(relative_path);
-  return (node == 0 ? UNSPECIFIED : (Type)(node->getType()));
+  return (node == 0 ? props::UNSPECIFIED : node->getType());
 }
 
 
@@ -2296,5 +2307,53 @@ SGPropertyChangeListener::unregister_property (SGPropertyNode * node)
     _properties.erase(it);
 }
 
+template<>
+std::ostream& SGRawBase<SGVec3d>::printOn(std::ostream& stream) const
+{
+    const SGVec3d vec
+        = static_cast<const SGRawValue<SGVec3d>*>(this)->getValue();
+    for (int i = 0; i < 3; ++i) {
+        stream << vec[i];
+        if (i < 2)
+            stream << ' ';
+    }
+    return stream;
+}
+
+namespace simgear
+{
+template<>
+std::istream& readFrom<SGVec3d>(std::istream& stream, SGVec3d& result)
+{
+    for (int i = 0; i < 3; ++i) {
+        stream >> result[i];
+    }
+    return stream;
+}
+}
+template<>
+std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const
+{
+    const SGVec4d vec
+        = static_cast<const SGRawValue<SGVec4d>*>(this)->getValue();    
+    for (int i = 0; i < 4; ++i) {
+        stream << vec[i];
+        if (i < 3)
+            stream << ' ';
+    }
+    return stream;
+}
+
+namespace simgear
+{
+template<>
+std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result)
+{
+    for (int i = 0; i < 4; ++i) {
+        stream >> result[i];
+    }
+    return stream;
+}
+}
 
 // end of props.cxx