-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
/*! \file loadcanvas.cpp
** \brief writeme
**
** $Id: loadcanvas.cpp,v 1.3 2005/01/04 23:40:44 darco Exp $
**
** \legal
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** 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.
**
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** 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
*/
/* ========================================================================= */
/* === U S I N G =========================================================== */
using namespace std;
-using namespace sinfg;
+using namespace synfig;
using namespace etl;
/*
class test_class {
static int bleh;
public:
- test_class() { assert(!bleh); bleh++; sinfg::info("test_class: initi: %d",bleh); }
- ~test_class() { assert(bleh); sinfg::info("test_class: uninit: %d",bleh); bleh--; }
+ test_class() { assert(!bleh); bleh++; synfig::info("test_class: initi: %d",bleh); }
+ ~test_class() { assert(bleh); synfig::info("test_class: uninit: %d",bleh); bleh--; }
};
int test_class::bleh(0);
static std::map<String, Canvas::LooseHandle>* open_canvas_map_(0);
-std::map<sinfg::String, etl::loose_handle<Canvas> >& sinfg::get_open_canvas_map()
+std::map<synfig::String, etl::loose_handle<Canvas> >& synfig::get_open_canvas_map()
{
if(!open_canvas_map_)
open_canvas_map_=new std::map<String, Canvas::LooseHandle>;
static void _canvas_file_name_changed(Canvas *x)
{
- std::map<sinfg::String, etl::loose_handle<Canvas> >::iterator iter;
+ std::map<synfig::String, etl::loose_handle<Canvas> >::iterator iter;
for(iter=get_open_canvas_map().begin();iter!=get_open_canvas_map().end();++iter)
if(iter->second==x)
}
Canvas::Handle
-sinfg::open_canvas(const String &filename)
+synfig::open_canvas(const String &filename)
{
CanvasParser parser;
}
Canvas::Handle
-sinfg::open_canvas_as(const String &filename,const String &as)
+synfig::open_canvas_as(const String &filename,const String &as)
{
CanvasParser parser;
}
Canvas::Handle
-sinfg::string_to_canvas(const String &data)
+synfig::string_to_canvas(const String &data)
{
CanvasParser parser;
CanvasParser::warning(xmlpp::Node *element, const String &text)
{
string str=strprintf("%s:<%s>:%d: warning: ",filename.c_str(),element->get_name().c_str(),element->get_line())+text;
- //sinfg::warning(str);
+ //synfig::warning(str);
cerr<<str<<endl;
total_warnings_++;
if(total_warnings_>=max_warnings_)
if(!allow_errors_)
throw runtime_error(str);
cerr<<str<<endl;
- // sinfg::error(str);
+ // synfig::error(str);
}
void
error(element, "Undefined value in <x>");
return Vector();
}
- xmlpp::TextNode *text=dynamic_cast<xmlpp::TextNode*>(child->get_children().front());
- if(!text)
- {
- error(element,"I need a number, not an element!");
- return Vector();
- }
- vect[0]=atof(text->get_content().c_str());
+ vect[0]=atof(child->get_child_text()->get_content().c_str());
}
else
if(child->get_name()=="y")
error(element, "Undefined value in <y>");
return Vector();
}
- xmlpp::TextNode *text=dynamic_cast<xmlpp::TextNode*>(child->get_children().front());
- if(!text)
- {
- error(element,"I need a number, not an element!");
- return Vector();
- }
- vect[1]=atof(text->get_content().c_str());
+ vect[1]=atof(child->get_child_text()->get_content().c_str());
}
else
error_unexpected_element(child,child->get_name());
return color;
}
-sinfg::String
+synfig::String
CanvasParser::parse_string(xmlpp::Element *element,Canvas::Handle canvas)
{
assert(element->get_name()=="string");
if(element->get_children().empty())
{
warning(element, "Undefined value in <string>");
- return sinfg::String();
+ return synfig::String();
}
if(element->get_child_text()->get_content().empty())
{
warning(element, "Content element of <string> appears to be empty");
- return sinfg::String();
+ return synfig::String();
}
return element->get_child_text()->get_content();
if(child->get_attribute("tension"))
{
- sinfg::String str(child->get_attribute("tension")->get_value());
+ synfig::String str(child->get_attribute("tension")->get_value());
waypoint->set_tension(atof(str.c_str()));
}
if(child->get_attribute("temporal-tension"))
{
- sinfg::String str(child->get_attribute("temporal-tension")->get_value());
+ synfig::String str(child->get_attribute("temporal-tension")->get_value());
waypoint->set_time_tension(atof(str.c_str()));
}
if(child->get_attribute("continuity"))
{
- sinfg::String str(child->get_attribute("continuity")->get_value());
+ synfig::String str(child->get_attribute("continuity")->get_value());
waypoint->set_continuity(atof(str.c_str()));
}
if(child->get_attribute("bias"))
{
- sinfg::String str(child->get_attribute("bias")->get_value());
+ synfig::String str(child->get_attribute("bias")->get_value());
waypoint->set_bias(atof(str.c_str()));
}
// Parse begin/end waypoints
{
- typedef sinfg::ValueNode_DynamicList::ListEntry::Activepoint Activepoint;
- typedef sinfg::ValueNode_DynamicList::ListEntry::ActivepointList ActivepointList;
+ typedef synfig::ValueNode_DynamicList::ListEntry::Activepoint Activepoint;
+ typedef synfig::ValueNode_DynamicList::ListEntry::ActivepointList ActivepointList;
String begin_sequence;
String end_sequence;
int space=timecode.find_first_of(' ');
priority=atoi(String(timecode,1,space-1).c_str());
timecode=String(timecode.begin()+space+1,timecode.end());
- //sinfg::info("priority: %d timecode: %s",priority,timecode.c_str());
+ //synfig::info("priority: %d timecode: %s",priority,timecode.c_str());
}
timing_info.push_back(
int space=timecode.find_first_of(' ');
priority=atoi(String(timecode,1,space-1).c_str());
timecode=String(timecode.begin()+space+1,timecode.end());
- //sinfg::info("priority: %d timecode: %s",priority,timecode.c_str());
+ //synfig::info("priority: %d timecode: %s",priority,timecode.c_str());
}
timing_info.push_back(
}
Canvas::Handle
-CanvasParser::parse_from_file_as(const String &file,const String &as)
+CanvasParser::parse_from_file_as(const String &file_,const String &as_)
{
CHECK_EXPIRE_TIME();
try
{
+ ChangeLocale change_locale(LC_NUMERIC, "C");
+ String file(unix_to_local_path(file_));
+ String as(unix_to_local_path(as_));
+
if(get_open_canvas_map().count(etl::absolute_path(as)))
return get_open_canvas_map()[etl::absolute_path(as)];
return canvas;
}
}
- catch(Exception::BadLinkName) { sinfg::error("BadLinkName Thrown"); }
- catch(Exception::BadType) { sinfg::error("BadType Thrown"); }
- catch(Exception::FileNotFound) { sinfg::error("FileNotFound Thrown"); }
- catch(Exception::IDNotFound) { sinfg::error("IDNotFound Thrown"); }
- catch(Exception::IDAlreadyExists) { sinfg::error("IDAlreadyExists Thrown"); }
+ catch(Exception::BadLinkName) { synfig::error("BadLinkName Thrown"); }
+ catch(Exception::BadType) { synfig::error("BadType Thrown"); }
+ catch(Exception::FileNotFound) { synfig::error("FileNotFound Thrown"); }
+ catch(Exception::IDNotFound) { synfig::error("IDNotFound Thrown"); }
+ catch(Exception::IDAlreadyExists) { synfig::error("IDAlreadyExists Thrown"); }
catch(const std::exception& ex)
{
- sinfg::error("Standard Exception: "+String(ex.what()));
+ synfig::error("Standard Exception: "+String(ex.what()));
return Canvas::Handle();
}
catch(const String& str)
{
cerr<<str<<endl;
- // sinfg::error(str);
+ // synfig::error(str);
return Canvas::Handle();
}
return Canvas::Handle();
try
{
+ ChangeLocale change_locale(LC_NUMERIC, "C");
filename=_("<INTERNAL>");
total_warnings_=0;
xmlpp::DomParser parser;
return canvas;
}
}
- catch(Exception::BadLinkName) { sinfg::error("BadLinkName Thrown"); }
- catch(Exception::BadType) { sinfg::error("BadType Thrown"); }
- catch(Exception::FileNotFound) { sinfg::error("FileNotFound Thrown"); }
- catch(Exception::IDNotFound) { sinfg::error("IDNotFound Thrown"); }
- catch(Exception::IDAlreadyExists) { sinfg::error("IDAlreadyExists Thrown"); }
+ catch(Exception::BadLinkName) { synfig::error("BadLinkName Thrown"); }
+ catch(Exception::BadType) { synfig::error("BadType Thrown"); }
+ catch(Exception::FileNotFound) { synfig::error("FileNotFound Thrown"); }
+ catch(Exception::IDNotFound) { synfig::error("IDNotFound Thrown"); }
+ catch(Exception::IDAlreadyExists) { synfig::error("IDAlreadyExists Thrown"); }
catch(const std::exception& ex)
{
- sinfg::error("Standard Exception: "+String(ex.what()));
+ synfig::error("Standard Exception: "+String(ex.what()));
return Canvas::Handle();
}
catch(const String& str)
{
cerr<<str<<endl;
- // sinfg::error(str);
+ // synfig::error(str);
return Canvas::Handle();
}
return Canvas::Handle();