tamlCustom.cpp
Engine/source/persistence/taml/tamlCustom.cpp
Public Variables
Detailed Description
Public Variables
FactoryCache< TamlCustomField > TamlCustomFieldFactory
FactoryCache< TamlCustomNode > TamlCustomNodeFactory
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2013 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "persistence/taml/tamlCustom.h" 25 26#ifndef _TAML_WRITE_NODE_H_ 27#include "persistence/taml/tamlWriteNode.h" 28#endif 29 30//----------------------------------------------------------------------------- 31 32FactoryCache<TamlCustomField> TamlCustomFieldFactory; 33FactoryCache<TamlCustomNode> TamlCustomNodeFactory; 34 35//----------------------------------------------------------------------------- 36 37void TamlCustomField::set( const char* pFieldName, const char* pFieldValue ) 38{ 39 // Sanity! 40 AssertFatal( pFieldName != NULL, "Field name cannot be NULL." ); 41 AssertFatal( pFieldValue != NULL, "Field value cannot be NULL." ); 42 43 // Set field name. 44 mFieldName = StringTable->insert( pFieldName ); 45 46#if TORQUE_DEBUG 47 // Is the field value too big? 48 if ( dStrlen(pFieldValue) >= sizeof(mFieldValue) ) 49 { 50 // Yes, so warn! 51 Con::warnf( "Taml property field '%s' has a value that exceeds then maximum length: '%s'", pFieldName, pFieldValue ); 52 AssertFatal( false, "Field value is too big!" ); 53 return; 54 } 55#endif 56 // Copy field value. 57 dStrcpy( mFieldValue, pFieldValue, MAX_TAML_NODE_FIELDVALUE_LENGTH ); 58} 59 60//----------------------------------------------------------------------------- 61 62void TamlCustomNode::setWriteNode( TamlWriteNode* pWriteNode ) 63{ 64 // Sanity! 65 AssertFatal( mNodeName != StringTable->EmptyString(), "Cannot set write node with an empty node name." ); 66 AssertFatal( pWriteNode != NULL, "Write node cannot be NULL." ); 67 AssertFatal( pWriteNode->mpSimObject == mpProxyObject, "Write node does not match existing proxy object." ); 68 AssertFatal( mpProxyWriteNode == NULL, "Field write node must be NULL." ); 69 70 // Set proxy write node. 71 mpProxyWriteNode = pWriteNode; 72} 73 74