Blender  V2.59
ExtraHandler.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: ExtraHandler.cpp 35841 2011-03-28 09:31:44Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): Nathan Letwory.
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00029 #include <stddef.h>
00030 #include "BLI_string.h"
00031 
00032 #include "ExtraHandler.h"
00033 
00034 ExtraHandler::ExtraHandler(DocumentImporter *dimp) : currentExtraTags(0)
00035 {
00036         this->dimp = dimp;
00037 }
00038 
00039 ExtraHandler::~ExtraHandler() {}
00040 
00041 bool ExtraHandler::elementBegin( const char* elementName, const char** attributes)
00042 {
00043         // \todo attribute handling for profile tags
00044         currentElement = std::string(elementName);
00045         return true;
00046 }
00047 
00048 bool ExtraHandler::elementEnd(const char* elementName )
00049 {
00050         return true;
00051 }
00052 
00053 bool ExtraHandler::textData(const char* text, size_t textLength)
00054 {
00055         char buf[1024];
00056         
00057         if(currentElement.length() == 0) return false;
00058         
00059         BLI_snprintf(buf, textLength+1, "%s", text);
00060         currentExtraTags->addTag(currentElement, std::string(buf));
00061         return true;
00062 }
00063 
00064 bool ExtraHandler::parseElement ( 
00065         const char* profileName, 
00066         const unsigned long& elementHash, 
00067         const COLLADAFW::UniqueId& uniqueId ) {
00068                 if(BLI_strcaseeq(profileName, "blender")) {
00069                         //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
00070                         currentUid = uniqueId;
00071                         ExtraTags *et = dimp->getExtraTags(uniqueId);
00072                         if(!et) {
00073                                 et = new ExtraTags(std::string(profileName));
00074                                 dimp->addExtraTags(uniqueId, et);
00075                         }
00076                         currentExtraTags = et;
00077                         return true;
00078                 }
00079                 //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
00080                 return false;
00081 }