Blender V2.61 - r43446

ExtraHandler.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Nathan Letwory.
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00027 #include <stddef.h>
00028 #include "BLI_string.h"
00029 
00030 #include "ExtraHandler.h"
00031 
00032 ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : currentExtraTags(0)
00033 {
00034     this->dimp = dimp;
00035     this->aimp = aimp;
00036 }
00037 
00038 ExtraHandler::~ExtraHandler() {}
00039 
00040 bool ExtraHandler::elementBegin( const char* elementName, const char** attributes)
00041 {
00042     // \todo attribute handling for profile tags
00043     currentElement = std::string(elementName);
00044     //addToSidTree(attributes[0], attributes[1]);
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 || currentExtraTags == 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 }