X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fimporter.cpp;fp=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fimporter.cpp;h=0000000000000000000000000000000000000000;hb=a095981e18cc37a8ecc7cd237cc22b9c10329264;hp=e27111072336416038de8dc564504baafaa104ee;hpb=9459638ad6797b8139f1e9f0715c96076dbf0890;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/importer.cpp b/synfig-core/trunk/src/synfig/importer.cpp deleted file mode 100644 index e271110..0000000 --- a/synfig-core/trunk/src/synfig/importer.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file importer.cpp -** \brief writeme -** -** $Id$ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#define SYNFIG_NO_ANGLE - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "canvas.h" -#include "importer.h" -#include "surface.h" -#include -#include "string.h" -#include -#include -#include - -#endif - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ - -using namespace etl; -using namespace std; -using namespace synfig; - -Importer::Book* synfig::Importer::book_; - -map *__open_importers; - -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -bool -Importer::subsys_init() -{ - book_=new Book(); - __open_importers=new map(); - return true; -} - -bool -Importer::subsys_stop() -{ - delete book_; - delete __open_importers; - return true; -} - -Importer::Book& -Importer::book() -{ - return *book_; -} - -Importer::Handle -Importer::open(const String &filename) -{ - if(filename.empty()) - { - synfig::error(_("Importer::open(): Cannot open empty filename")); - return 0; - } - - // If we already have an importer open under that filename, - // then use it instead. - if(__open_importers->count(filename)) - { - //synfig::info("Found importer already open, using it..."); - return (*__open_importers)[filename]; - } - - if(filename_extension(filename) == "") - { - synfig::error(_("Importer::open(): Couldn't find extension")); - return 0; - } - - String ext(filename_extension(filename)); - if (ext.size()) ext = ext.substr(1); // skip initial '.' - std::transform(ext.begin(),ext.end(),ext.begin(),&::tolower); - - - if(!Importer::book().count(ext)) - { - synfig::error(_("Importer::open(): Unknown file type -- ")+ext); - return 0; - } - - try { - Importer::Handle importer; - importer=Importer::book()[ext](filename.c_str()); - (*__open_importers)[filename]=importer; - return importer; - } - catch (String str) - { - synfig::error(str); - } - return 0; -} - -Importer::Importer(): - gamma_(2.2) -{ -} - - -Importer::~Importer() -{ - // Remove ourselves from the open importer list - map::iterator iter; - for(iter=__open_importers->begin();iter!=__open_importers->end();++iter) - if(iter->second==this) - { - __open_importers->erase(iter); - } -}