/[svn]/libgig/trunk/src/Serialization.cpp
ViewVC logotype

Diff of /libgig/trunk/src/Serialization.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3185 by schoenebeck, Wed May 17 15:42:58 2017 UTC revision 3333 by schoenebeck, Sat Jul 29 09:57:08 2017 UTC
# Line 250  namespace Serialization { Line 250  namespace Serialization {
250       * characteristic is compared as well. So a @c double type and @c double*       * characteristic is compared as well. So a @c double type and @c double*
251       * type are also considered to be not equal data types and hence this method       * type are also considered to be not equal data types and hence this method
252       * would return @c false.       * would return @c false.
253         *
254         * As an exception here, classes and structs with the same class/struct name
255         * but different sizes are also considered to be "equal". This relaxed
256         * requirement is necessary to retain backward compatiblity to older
257         * versions of the same native C++ classes/structs.
258       */       */
259      bool DataType::operator==(const DataType& other) const {      bool DataType::operator==(const DataType& other) const {
260          return m_baseTypeName   == other.m_baseTypeName &&          return m_baseTypeName   == other.m_baseTypeName &&
261                 m_customTypeName == other.m_customTypeName &&                 m_customTypeName == other.m_customTypeName &&
262                 m_size           == other.m_size &&                 (m_size == other.m_size || (isClass() && other.isClass())) &&
263                 m_isPointer      == other.m_isPointer;                 m_isPointer      == other.m_isPointer;
264      }      }
265    
# Line 2090  namespace Serialization { Line 2095  namespace Serialization {
2095                  setBoolValue(object, false);                  setBoolValue(object, false);
2096              else              else
2097                  setBoolValue(object, atof(value.c_str()));                  setBoolValue(object, atof(value.c_str()));
2098          } else if (type.isEnum())          } else if (type.isEnum())
2099              setEnumValue(object, atoll(value.c_str()));              setEnumValue(object, atoll(value.c_str()));
2100          else          else
2101              throw Exception("Not a primitive data type");              throw Exception("Not a primitive data type");
# Line 2286  namespace Serialization { Line 2291  namespace Serialization {
2291      // *************** Exception ***************      // *************** Exception ***************
2292      // *      // *
2293    
2294        Exception::Exception() {
2295        }
2296    
2297        Exception::Exception(String format, ...) {
2298            va_list arg;
2299            va_start(arg, format);
2300            Message = assemble(format, arg);
2301            va_end(arg);
2302        }
2303    
2304        Exception::Exception(String format, va_list arg) {
2305            Message = assemble(format, arg);
2306        }
2307    
2308      /** @brief Print exception message to stdout.      /** @brief Print exception message to stdout.
2309       *       *
2310       * Prints the message of this Exception to the currently defined standard       * Prints the message of this Exception to the currently defined standard
# Line 2295  namespace Serialization { Line 2314  namespace Serialization {
2314          std::cout << "Serialization::Exception: " << Message << std::endl;          std::cout << "Serialization::Exception: " << Message << std::endl;
2315      }      }
2316    
2317        String Exception::assemble(String format, va_list arg) {
2318            char* buf = NULL;
2319            vasprintf(&buf, format.c_str(), arg);
2320            String s = buf;
2321            free(buf);
2322            return s;
2323        }
2324    
2325  } // namespace Serialization  } // namespace Serialization

Legend:
Removed from v.3185  
changed lines
  Added in v.3333

  ViewVC Help
Powered by ViewVC