[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4003 - in trunk/pingus: . src src/actions src/components s
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4003 - in trunk/pingus: . src src/actions src/components src/editor src/input src/util src/worldmap src/worldobjs |
Date: |
Wed, 4 Nov 2009 01:33:35 +0100 |
Author: grumbel
Date: 2009-11-04 01:33:25 +0100 (Wed, 04 Nov 2009)
New Revision: 4003
Added:
trunk/pingus/src/util/
trunk/pingus/src/util/debug_stream.cpp
trunk/pingus/src/util/debug_stream.hpp
trunk/pingus/src/util/file_reader.cpp
trunk/pingus/src/util/file_reader.hpp
trunk/pingus/src/util/file_reader_impl.hpp
trunk/pingus/src/util/file_writer.hpp
trunk/pingus/src/util/sexpr_file_reader.cpp
trunk/pingus/src/util/sexpr_file_reader.hpp
trunk/pingus/src/util/sexpr_file_writer.cpp
trunk/pingus/src/util/sexpr_file_writer.hpp
trunk/pingus/src/util/string_util.cpp
trunk/pingus/src/util/string_util.hpp
trunk/pingus/src/util/system.cpp
trunk/pingus/src/util/system.hpp
trunk/pingus/src/util/utf8.cpp
trunk/pingus/src/util/utf8.hpp
Removed:
trunk/pingus/src/debug_stream.cpp
trunk/pingus/src/debug_stream.hpp
trunk/pingus/src/file_reader.cpp
trunk/pingus/src/file_reader.hpp
trunk/pingus/src/file_reader_impl.hpp
trunk/pingus/src/file_writer.hpp
trunk/pingus/src/sexpr_file_reader.cpp
trunk/pingus/src/sexpr_file_reader.hpp
trunk/pingus/src/sexpr_file_writer.cpp
trunk/pingus/src/sexpr_file_writer.hpp
trunk/pingus/src/string_util.cpp
trunk/pingus/src/string_util.hpp
trunk/pingus/src/system.cpp
trunk/pingus/src/system.hpp
trunk/pingus/src/utf8.cpp
trunk/pingus/src/utf8.hpp
Modified:
trunk/pingus/SConstruct
trunk/pingus/src/action_holder.cpp
trunk/pingus/src/actions/bridger.cpp
trunk/pingus/src/blitter.cpp
trunk/pingus/src/capture_rectangle.cpp
trunk/pingus/src/collision_mask.cpp
trunk/pingus/src/components/action_button.cpp
trunk/pingus/src/components/button_panel.cpp
trunk/pingus/src/components/time_display.cpp
trunk/pingus/src/config_manager.cpp
trunk/pingus/src/debug.hpp
trunk/pingus/src/editor/action_properties.cpp
trunk/pingus/src/editor/editor_level.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/file_dialog.cpp
trunk/pingus/src/editor/file_list.hpp
trunk/pingus/src/editor/level_objs.hpp
trunk/pingus/src/editor/level_properties.cpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/font.cpp
trunk/pingus/src/font_description.cpp
trunk/pingus/src/font_test_screen.cpp
trunk/pingus/src/input/driver.hpp
trunk/pingus/src/input/manager.cpp
trunk/pingus/src/input/sdl_driver.cpp
trunk/pingus/src/level_menu.cpp
trunk/pingus/src/levelset.cpp
trunk/pingus/src/path_manager.cpp
trunk/pingus/src/pathname.cpp
trunk/pingus/src/pingus_demo.cpp
trunk/pingus/src/pingus_level.cpp
trunk/pingus/src/pingus_level.hpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/plf_res_mgr.cpp
trunk/pingus/src/resource.cpp
trunk/pingus/src/resource_manager.cpp
trunk/pingus/src/result_screen.cpp
trunk/pingus/src/savegame.cpp
trunk/pingus/src/savegame.hpp
trunk/pingus/src/savegame_manager.cpp
trunk/pingus/src/screenshot.cpp
trunk/pingus/src/server.cpp
trunk/pingus/src/server_event.cpp
trunk/pingus/src/server_event.hpp
trunk/pingus/src/sprite_description.hpp
trunk/pingus/src/start_screen.cpp
trunk/pingus/src/stat_manager.cpp
trunk/pingus/src/story_screen.cpp
trunk/pingus/src/string_format.cpp
trunk/pingus/src/worldmap/dot.cpp
trunk/pingus/src/worldmap/drawable.hpp
trunk/pingus/src/worldmap/level_dot.cpp
trunk/pingus/src/worldmap/path_graph.cpp
trunk/pingus/src/worldmap/pingus_worldmap.cpp
trunk/pingus/src/worldmap/worldmap.cpp
trunk/pingus/src/worldmap/worldmap.hpp
trunk/pingus/src/worldmap/worldmap_story.cpp
trunk/pingus/src/worldobj.hpp
trunk/pingus/src/worldobj_factory.hpp
trunk/pingus/src/worldobjs/exit.cpp
Log:
Move utility classes to util/ directory
Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/SConstruct 2009-11-04 00:33:25 UTC (rev 4003)
@@ -35,10 +35,10 @@
'src/config_manager.cpp',
'src/credits.cpp',
'src/debug.cpp',
-'src/debug_stream.cpp',
+'src/util/debug_stream.cpp',
'src/demo_session.cpp',
'src/direction.cpp',
-'src/file_reader.cpp',
+'src/util/file_reader.cpp',
'src/font.cpp',
'src/font_description.cpp',
'src/font_test_screen.cpp',
@@ -82,8 +82,8 @@
'src/screenshot.cpp',
'src/server.cpp',
'src/server_event.cpp',
-'src/sexpr_file_reader.cpp',
-'src/sexpr_file_writer.cpp',
+'src/util/sexpr_file_reader.cpp',
+'src/util/sexpr_file_writer.cpp',
'src/smallmap_image.cpp',
'src/sprite.cpp',
'src/sprite_impl.cpp',
@@ -92,10 +92,10 @@
'src/state_sprite.cpp',
'src/story_screen.cpp',
'src/string_format.cpp',
-'src/string_util.cpp',
+'src/util/string_util.cpp',
'src/surface.cpp',
-'src/system.cpp',
-'src/utf8.cpp',
+'src/util/system.cpp',
+'src/util/utf8.cpp',
'src/world.cpp',
'src/worldobj.cpp',
'src/worldobj_factory.cpp',
Modified: trunk/pingus/src/action_holder.cpp
===================================================================
--- trunk/pingus/src/action_holder.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/action_holder.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
+
#include "pingus_level.hpp"
#include "action_holder.hpp"
Modified: trunk/pingus/src/actions/bridger.cpp
===================================================================
--- trunk/pingus/src/actions/bridger.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/actions/bridger.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -22,7 +22,7 @@
#include "../world.hpp"
#include "../worldobj.hpp"
#include "../gettext.h"
-#include "../string_util.hpp"
+#include "util/string_util.hpp"
#include "bridger.hpp"
namespace Actions {
Modified: trunk/pingus/src/blitter.cpp
===================================================================
--- trunk/pingus/src/blitter.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/blitter.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -19,7 +19,7 @@
#include <assert.h>
#include "SDL.h"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "pingus_error.hpp"
#include "globals.hpp"
#include "math.hpp"
Modified: trunk/pingus/src/capture_rectangle.cpp
===================================================================
--- trunk/pingus/src/capture_rectangle.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/capture_rectangle.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "math/vector3f.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "pingu.hpp"
#include "resource.hpp"
#include "capture_rectangle.hpp"
Modified: trunk/pingus/src/collision_mask.cpp
===================================================================
--- trunk/pingus/src/collision_mask.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/collision_mask.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <iostream>
#include "resource.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "collision_mask.hpp"
CollisionMask::CollisionMask()
Modified: trunk/pingus/src/components/action_button.cpp
===================================================================
--- trunk/pingus/src/components/action_button.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/components/action_button.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -21,7 +21,7 @@
#include "../world.hpp"
#include "../display/drawing_context.hpp"
#include "../fonts.hpp"
-#include "../string_util.hpp"
+#include "util/string_util.hpp"
#include "../math/vector3f.hpp"
using namespace Actions;
Modified: trunk/pingus/src/components/button_panel.cpp
===================================================================
--- trunk/pingus/src/components/button_panel.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/components/button_panel.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -18,7 +18,7 @@
#include <algorithm>
#include "../math.hpp"
#include "../fonts.hpp"
-#include "../string_util.hpp"
+#include "util/string_util.hpp"
#include "../globals.hpp"
#include "../server.hpp"
#include "../game_session.hpp"
Modified: trunk/pingus/src/components/time_display.cpp
===================================================================
--- trunk/pingus/src/components/time_display.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/components/time_display.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -24,7 +24,7 @@
#include "../server.hpp"
#include "../game_session.hpp"
#include "../game_time.hpp"
-#include "../string_util.hpp"
+#include "util/string_util.hpp"
#include "../fonts.hpp"
#include "time_display.hpp"
Modified: trunk/pingus/src/config_manager.cpp
===================================================================
--- trunk/pingus/src/config_manager.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/config_manager.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -18,13 +18,13 @@
#include <fstream>
#include "SDL.h"
#include "globals.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "fps_counter.hpp"
#include "display/display.hpp"
#include "screen/screen_manager.hpp"
#include "tinygettext/dictionary_manager.hpp"
-#include "sexpr_file_reader.hpp"
-#include "sexpr_file_writer.hpp"
+#include "util/sexpr_file_reader.hpp"
+#include "util/sexpr_file_writer.hpp"
#include "config_manager.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
Modified: trunk/pingus/src/debug.hpp
===================================================================
--- trunk/pingus/src/debug.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/debug.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -17,7 +17,7 @@
#ifndef HEADER_PINGUS_DEBUG_HPP
#define HEADER_PINGUS_DEBUG_HPP
-#include "debug_stream.hpp"
+#include "util/debug_stream.hpp"
/* Stream for error messages */
Deleted: trunk/pingus/src/debug_stream.cpp
===================================================================
--- trunk/pingus/src/debug_stream.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/debug_stream.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,159 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "debug_stream.hpp"
-#include "globals.hpp"
-
-using std::ostream;
-
-
-NilStream DebugStream::nilstream;
-
-DebugStream::Buffer::Buffer (const std::string& p)
- : prefix (p)
-{
- // Set the output buffer
- setp (char_buffer, char_buffer + buffersize - 1);
-
- // Switch of input buffer
- setg(0, 0, 0);
-}
-
-DebugStream::Buffer::~Buffer ()
-{
- sync ();
-}
-
-int
-DebugStream::Buffer::overflow (int c)
-{
- std::string str;
-
- for (char* ptr = pbase (); ptr != pptr (); ++ptr)
- {
- str += *ptr;
-
- if (*ptr == '\n')
- {
- put_line (prefix + str);
- str = "";
- }
- }
- str += c;
- put_line (str);
-
- setp (char_buffer, char_buffer + buffersize - 1);
- return 0;
-}
-
-void
-DebugStream::Buffer::put_line (const std::string& line)
-{
- if (!out_streams.empty ())
- {
- for (std::vector<std::ostream*>::iterator i = out_streams.begin ();
- i != out_streams.end (); ++i)
- {
- *(*i) << line << std::flush;
- }
- }
- else
- {
- std::cout << "[DebugStream::Buffer fallback stream] " << line;
- }
-}
-
-int
-DebugStream::Buffer::sync ()
-{
- std::string str;
-
- // Walk through the buffer
- for (char* c = pbase (); c != pptr (); ++c)
- {
- str += *c;
-
- if (*c == '\n')
- {
- put_line (prefix + str);
- str = "";
- }
- }
-
- if (!str.empty ())
- put_line (str);
-
- setp (char_buffer, char_buffer + buffersize - 1);
- return 0;
-}
-
-void
-DebugStream::Buffer::add (ostream& s)
-{
- out_streams.push_back (&s);
-}
-
-
-void
-DebugStream::Buffer::set_prefix (const std::string & prefix_)
-{
- prefix = prefix_;
-}
-
-
-// ----------------------------------------------------------------
-
-
-DebugStream::DebugStream (const std::string& prefix)
- : ostream (&buffer),
- buffer (prefix)
-{
-}
-
-DebugStream::~DebugStream ()
-{
-}
-
-/// returns self if the debug flag is set, else nilstream
-ostream & DebugStream::operator () (int component) {
-
- if (pingus_debug_flags & component) {
- return *this;
- } else {
- return nilstream;
- }
-}
-
-void
-DebugStream::add (ostream& s)
-{
- buffer.add (s);
-}
-
-void
-DebugStream::set_prefix (const std::string & prefix)
-{
- buffer.set_prefix(prefix);
-}
-
-
-NilStream::NilStream ()
- : ostream(&buffer)
-{
-}
-
-
-/* EOF */
Deleted: trunk/pingus/src/debug_stream.hpp
===================================================================
--- trunk/pingus/src/debug_stream.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/debug_stream.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,121 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_DEBUG_STREAM_HPP
-#define HEADER_PINGUS_DEBUG_STREAM_HPP
-
-#include "pingus.hpp"
-#include <string>
-#include <vector>
-#include <iostream>
-
-
-class NilStream;
-
-class DebugStream : public std::ostream
-{
-
-private:
-
- class Buffer : public std::streambuf
- {
- private:
-
- enum { buffersize = 1024 };
-
- std::vector<std::ostream*> out_streams;
-
- char char_buffer[buffersize];
- std::string prefix;
-
- public:
-
- Buffer (const std::string& prefix);
- virtual ~Buffer ();
-
- int overflow (int c);
- int sync ();
-
- void add (std::ostream& s);
- void set_prefix (const std::string & prefix_);
-
- private:
-
- void put_line (const std::string& line);
-
- } buffer;
-
- static NilStream nilstream;
-
-public:
-
- DebugStream (const std::string& prefix);
- virtual ~DebugStream ();
-
- std::ostream & operator() (int component);
-
- void add (std::ostream& s);
- void set_prefix (const std::string & prefix);
-
-private:
- DebugStream (const DebugStream&);
- DebugStream& operator= (const DebugStream&);
-};
-
-
-
-/// Stream used to consume unwanted debugmessages
-class NilStream : public std::ostream
-{
- private:
-
- /// Do nothing Buffer for NilStream
- class NilBuffer : public std::streambuf
- {
- private:
-
- char char_buffer[4];
-
- public:
-
- NilBuffer () { setp(char_buffer, char_buffer + 3); setg(0,0,0); }
- ~NilBuffer () { }
-
- int overflow (int) { return 0; }
- int sync () { return 0; }
- } buffer;
-
- NilStream ();
- ~NilStream () { }
-
- NilStream (const NilStream &); ///< not supported
-
- public:
-
- // Avoid unneccessary calls to internal buffer and conversions
- NilStream & operator << (const char *) { return *this; }
- NilStream & operator << (const std::string &) { return *this; }
- NilStream & operator << (int &) { return *this; }
- NilStream & operator << (unsigned int &) { return *this; }
-
-
- friend class DebugStream;
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/editor/action_properties.cpp
===================================================================
--- trunk/pingus/src/editor/action_properties.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/editor/action_properties.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -21,7 +21,7 @@
#include "editor_level.hpp"
#include "pingu_enums.hpp"
#include "inputbox.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "action_properties.hpp"
namespace Editor {
Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/editor/editor_level.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -25,7 +25,7 @@
#include "level_objs.hpp"
#include "pathname.hpp"
#include "../pingus_level.hpp"
-#include "../sexpr_file_writer.hpp"
+#include "util/sexpr_file_writer.hpp"
namespace Editor {
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/editor/editor_screen.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -17,8 +17,9 @@
#include <iostream>
#include <boost/bind.hpp>
+
#include "../display/display.hpp"
-#include "../system.hpp"
+#include "util/system.hpp"
#include "../sound/sound.hpp"
#include "../gui/gui_manager.hpp"
#include "../screen/screen_manager.hpp"
Modified: trunk/pingus/src/editor/file_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_dialog.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/editor/file_dialog.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -16,10 +16,11 @@
#include <iostream>
#include <boost/bind.hpp>
+
#include "display/drawing_context.hpp"
#include "gui/gui_manager.hpp"
#include "editor_screen.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "gui_style.hpp"
#include "fonts.hpp"
#include "gettext.h"
Modified: trunk/pingus/src/editor/file_list.hpp
===================================================================
--- trunk/pingus/src/editor/file_list.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/editor/file_list.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -18,7 +18,7 @@
#define HEADER_FILE_LIST_HPP
#include <boost/signal.hpp>
-#include "system.hpp"
+#include "util/system.hpp"
#include "sprite.hpp"
#include "gui/rect_component.hpp"
Modified: trunk/pingus/src/editor/level_objs.hpp
===================================================================
--- trunk/pingus/src/editor/level_objs.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/editor/level_objs.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -23,7 +23,7 @@
#include "../math/rect.hpp"
#include "../math/vector3f.hpp"
#include "../res_descriptor.hpp"
-#include "../file_writer.hpp"
+#include "util/file_writer.hpp"
#include <string>
Modified: trunk/pingus/src/editor/level_properties.cpp
===================================================================
--- trunk/pingus/src/editor/level_properties.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/editor/level_properties.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -16,7 +16,8 @@
#include <iostream>
#include <boost/bind.hpp>
-#include "string_util.hpp"
+
+#include "util/string_util.hpp"
#include "label.hpp"
#include "inputbox.hpp"
#include "gui_style.hpp"
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/editor/object_properties.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -17,7 +17,7 @@
#include <boost/bind.hpp>
#include <iostream>
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "button.hpp"
#include "editor_screen.hpp"
#include "level_objs.hpp"
Deleted: trunk/pingus/src/file_reader.cpp
===================================================================
--- trunk/pingus/src/file_reader.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/file_reader.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,230 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "sexpr_file_reader.hpp"
-#include "lisp/parser.hpp"
-#include "lisp/lisp.hpp"
-#include "pathname.hpp"
-#include "file_reader.hpp"
-#include "file_reader_impl.hpp"
-
-FileReader::FileReader(boost::shared_ptr<FileReaderImpl> impl_)
- : impl(impl_)
-{
-}
-
-FileReader::FileReader()
-{
-}
-
-std::string
-FileReader::get_name() const
-{
- if (impl.get())
- return impl->get_name();
- else
- return "";
-}
-
-bool
-FileReader::read_int(const char* name, int& value) const
-{
- if (impl.get())
- return impl->read_int(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_float (const char* name, float& value) const
-{
- if (impl.get())
- return impl->read_float(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_bool (const char* name, bool& value) const
-{
- if (impl.get())
- return impl->read_bool(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_string(const char* name, std::string& value) const
-{
- if (impl.get())
- return impl->read_string(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_path(const char* name, Pathname& value) const
-{
- if (impl.get())
- {
- std::string filename;
- if (impl->read_string(name, filename))
- {
- value = Pathname(filename, Pathname::DATA_PATH);
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- return false;
-}
-
-bool
-FileReader::read_vector(const char* name, Vector3f& value) const
-{
- if (impl.get())
- return impl->read_vector(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_color(const char* name, Color& value) const
-{
- if (impl.get())
- return impl->read_color(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_desc(const char* name, ResDescriptor& desc) const
-{
- if (impl.get())
- return impl->read_desc(name, desc);
- else
- return false;
-}
-
-bool
-FileReader::read_size (const char* name, Size& value) const
-{
- if (impl.get())
- return impl->read_size(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_vector2i(const char* name, Vector2i& value) const
-{
- if (impl.get())
- return impl->read_vector2i(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_rect(const char* name, Rect& value) const
-{
- if (impl.get())
- return impl->read_rect(name, value);
- else
- return false;
-}
-
-bool
-FileReader::read_section(const char* name, FileReader& reader) const
-{
- if (impl.get())
- return impl->read_section(name, reader);
- else
- return false;
-}
-
-std::vector<std::string>
-FileReader::get_section_names() const
-{
- if (impl.get())
- return impl->get_section_names();
- else
- return std::vector<std::string>();
-}
-
-std::vector<FileReader>
-FileReader::get_sections() const
-{
- if (impl.get())
- return impl->get_sections();
- else
- return std::vector<FileReader>();
-}
-
-int
-FileReader::get_num_sections() const
-{
- return int(impl->get_sections().size());
-}
-
-FileReader
-FileReader::read_section(const char* name) const
-{
- FileReader reader;
- read_section(name, reader);
- return reader;
-}
-
-FileReader
-FileReader::parse(const std::string& filename)
-{
- boost::shared_ptr<lisp::Lisp> sexpr = lisp::Parser::parse(filename);
- if (sexpr)
- {
- return SExprFileReader(sexpr->get_list_elem(0));
- }
- else
- {
- return FileReader();
- }
-}
-
-FileReader
-FileReader::parse(const Pathname& pathname)
-{
- return FileReader::parse(pathname.get_sys_path());
-}
-
-std::vector<FileReader>
-FileReader::parse_many(const Pathname& pathname)
-{
- boost::shared_ptr<lisp::Lisp> sexpr =
lisp::Parser::parse(pathname.get_sys_path());
- if (sexpr)
- {
- std::vector<FileReader> sections;
- for(size_t i = 0; i < sexpr->get_list_size(); ++i)
- sections.push_back(SExprFileReader(sexpr->get_list_elem(i)));
- return sections;
- }
- else
- {
- return std::vector<FileReader>();
- }
-}
-
-/* EOF */
Deleted: trunk/pingus/src/file_reader.hpp
===================================================================
--- trunk/pingus/src/file_reader.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/file_reader.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,86 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_FILE_READER_HPP
-#define HEADER_PINGUS_FILE_READER_HPP
-
-#include <string>
-#include <vector>
-#include <boost/shared_ptr.hpp>
-
-class Size;
-class Color;
-class Vector3f;
-class Vector2i;
-class Rect;
-
-class ResDescriptor;
-class FileReaderImpl;
-class Pathname;
-
-/** Interface to read name/value pairs out of some kind of file or
- structure */
-class FileReader
-{
-public:
- FileReader(boost::shared_ptr<FileReaderImpl> impl_);
- FileReader();
-
- /** Name of the current section, ie. in the case of
- <groundpiece><pos>...</groundpiece> it would be 'groundpiece' */
- std::string get_name() const;
-
- bool read_int (const char* name, int&) const;
- bool read_float (const char* name, float&) const;
- bool read_bool (const char* name, bool&) const;
- bool read_string(const char* name, std::string&) const;
- bool read_path (const char* name, Pathname&) const;
- bool read_vector(const char* name, Vector3f&) const;
- bool read_vector2i(const char* name, Vector2i&) const;
- bool read_rect(const char* name, Rect&) const;
- bool read_size (const char* name, Size&) const;
- bool read_color (const char* name, Color&) const;
- bool read_desc (const char* name, ResDescriptor&) const;
- bool read_section(const char* name, FileReader&) const;
- FileReader read_section(const char* name) const;
-
- template<class E, class T>
- bool read_enum (const char* name, E& value, T enum2string) const
- {
- std::string str;
- if (read_string(name, str))
- {
- value = enum2string(str);
- return true;
- }
-
- return false;
- }
-
- std::vector<std::string> get_section_names() const;
- std::vector<FileReader> get_sections() const;
- int get_num_sections() const;
-
- static FileReader parse(const std::string& filename);
- static FileReader parse(const Pathname& pathname);
- static std::vector<FileReader> parse_many(const Pathname& pathname);
-private:
- boost::shared_ptr<FileReaderImpl> impl;
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/file_reader_impl.hpp
===================================================================
--- trunk/pingus/src/file_reader_impl.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/file_reader_impl.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -1,55 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_FILE_READER_IMPL_HPP
-#define HEADER_FILE_READER_IMPL_HPP
-
-#include <vector>
-#include <string>
-
-class Size;
-class Color;
-class Vector3f;
-class Vector2i;
-
-class FileReader;
-class ResDescriptor;
-
-class FileReaderImpl
-{
-public:
- FileReaderImpl() {}
- virtual ~FileReaderImpl() {}
-
- virtual std::string get_name() const =0;
- virtual bool read_int (const char* name, int&) const =0;
- virtual bool read_float (const char* name, float&) const =0;
- virtual bool read_bool (const char* name, bool&) const =0;
- virtual bool read_string(const char* name, std::string&) const =0;
- virtual bool read_vector(const char* name, Vector3f&) const =0;
- virtual bool read_size (const char* name, Size&) const =0;
- virtual bool read_vector2i(const char* name, Vector2i&) const =0;
- virtual bool read_rect (const char* name, Rect&) const =0;
- virtual bool read_color (const char* name, Color&) const =0;
- virtual bool read_desc (const char* name, ResDescriptor&) const =0;
- virtual bool read_section(const char* name, FileReader&) const =0;
- virtual std::vector<FileReader> get_sections() const =0;
- virtual std::vector<std::string> get_section_names() const =0;
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/file_writer.hpp
===================================================================
--- trunk/pingus/src/file_writer.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/file_writer.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,50 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_FILE_WRITER_HPP
-#define HEADER_PINGUS_FILE_WRITER_HPP
-
-#include <string>
-
-
-class Vector3f;
-class Size;
-class Color;
-
-/** Interface to write out name/value pairs out of some kind of file or
- structure */
-class FileWriter
-{
-private:
-public:
- virtual ~FileWriter() {}
-
- virtual void begin_section (const char* name) =0;
- virtual void end_section () =0;
-
- virtual void write_int (const char* name, int) =0;
- virtual void write_float (const char* name, float) =0;
- virtual void write_color (const char* name, const Color&) =0;
- virtual void write_bool (const char* name, bool) =0;
- virtual void write_string (const char* name, const std::string&) =0;
- virtual void write_vector (const char* name, const Vector3f&) =0;
- virtual void write_size (const char* name, const Size&) = 0;
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/font.cpp
===================================================================
--- trunk/pingus/src/font.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/font.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -22,7 +22,7 @@
#include "font.hpp"
#include "surface.hpp"
#include "line_iterator.hpp"
-#include "utf8.hpp"
+#include "util/utf8.hpp"
#include "font_description.hpp"
#include "display/framebuffer.hpp"
#include "display/display.hpp"
Modified: trunk/pingus/src/font_description.cpp
===================================================================
--- trunk/pingus/src/font_description.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/font_description.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -15,9 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "pingus_error.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "font_description.hpp"
-
GlyphDescription::GlyphDescription()
: image(0), unicode(0), advance(0)
Modified: trunk/pingus/src/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/font_test_screen.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/font_test_screen.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -18,7 +18,7 @@
#include "input/event.hpp"
#include "fonts.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "display/drawing_context.hpp"
#include "display/display.hpp"
#include "font_description.hpp"
Modified: trunk/pingus/src/input/driver.hpp
===================================================================
--- trunk/pingus/src/input/driver.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/input/driver.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -17,7 +17,7 @@
#ifndef HEADER_PINGUS_INPUT_DRIVER_HPP
#define HEADER_PINGUS_INPUT_DRIVER_HPP
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "control.hpp"
namespace Input {
Modified: trunk/pingus/src/input/manager.cpp
===================================================================
--- trunk/pingus/src/input/manager.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/input/manager.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include "config.h"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "pingus_error.hpp"
#include "pathname.hpp"
#include "path_manager.hpp"
Modified: trunk/pingus/src/input/sdl_driver.cpp
===================================================================
--- trunk/pingus/src/input/sdl_driver.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/input/sdl_driver.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -17,7 +17,7 @@
#include "global_event.hpp"
#include "screen/screen_manager.hpp"
#include "math/size.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "display/display.hpp"
#include "sdl_driver.hpp"
Modified: trunk/pingus/src/level_menu.cpp
===================================================================
--- trunk/pingus/src/level_menu.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/level_menu.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -23,7 +23,7 @@
#include "fonts.hpp"
#include "display/drawing_context.hpp"
#include "option_menu.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "display/display.hpp"
#include "level_menu.hpp"
#include "gui/rect_component.hpp"
Modified: trunk/pingus/src/levelset.cpp
===================================================================
--- trunk/pingus/src/levelset.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/levelset.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <iostream>
#include "pingus_error.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "levelset.hpp"
#include "plf_res_mgr.hpp"
#include "savegame_manager.hpp"
Modified: trunk/pingus/src/path_manager.cpp
===================================================================
--- trunk/pingus/src/path_manager.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/path_manager.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <sstream>
#include "globals.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "debug.hpp"
#include "path_manager.hpp"
Modified: trunk/pingus/src/pathname.cpp
===================================================================
--- trunk/pingus/src/pathname.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/pathname.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <assert.h>
#include <iostream>
-#include "system.hpp"
+#include "util/system.hpp"
#include "path_manager.hpp"
#include "pathname.hpp"
Modified: trunk/pingus/src/pingus_demo.cpp
===================================================================
--- trunk/pingus/src/pingus_demo.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/pingus_demo.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -17,7 +17,7 @@
#include <stdexcept>
#include <fstream>
#include "pathname.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "server_event.hpp"
#include "pingus_error.hpp"
#include "pingu_enums.hpp"
Modified: trunk/pingus/src/pingus_level.cpp
===================================================================
--- trunk/pingus/src/pingus_level.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/pingus_level.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -15,7 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
-#include "file_reader.hpp"
+
+#include "util/file_reader.hpp"
#include "pingus_level.hpp"
#include "pingus_error.hpp"
#include "pingus_level_impl.hpp"
Modified: trunk/pingus/src/pingus_level.hpp
===================================================================
--- trunk/pingus/src/pingus_level.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/pingus_level.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -21,8 +21,9 @@
#include <vector>
#include <map>
#include <boost/shared_ptr.hpp>
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
+
class Pathname;
class FileReader;
class PingusLevelImpl;
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/pingus_main.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -23,9 +23,9 @@
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "editor/editor_level.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "demo_session.hpp"
-#include "sexpr_file_reader.hpp"
+#include "util/sexpr_file_reader.hpp"
#include "fonts.hpp"
#include "config_manager.hpp"
#include "display/display.hpp"
@@ -61,7 +61,7 @@
#include "path_manager.hpp"
#include "pingus_main.hpp"
#include "globals.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "pingus_error.hpp"
#include "fps_counter.hpp"
#include "plf_res_mgr.hpp"
Modified: trunk/pingus/src/plf_res_mgr.cpp
===================================================================
--- trunk/pingus/src/plf_res_mgr.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/plf_res_mgr.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include "globals.hpp"
#include "debug.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "pathname.hpp"
#include "plf_res_mgr.hpp"
Modified: trunk/pingus/src/resource.cpp
===================================================================
--- trunk/pingus/src/resource.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/resource.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <assert.h>
-#include "system.hpp"
+#include "util/system.hpp"
#include "path_manager.hpp"
#include "globals.hpp"
#include "font_description.hpp"
Modified: trunk/pingus/src/resource_manager.cpp
===================================================================
--- trunk/pingus/src/resource_manager.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/resource_manager.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -19,9 +19,9 @@
#include "globals.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
#include "sprite_description.hpp"
-#include "sexpr_file_reader.hpp"
+#include "util/sexpr_file_reader.hpp"
#include "resource_manager.hpp"
ResourceManager::ResourceManager()
Modified: trunk/pingus/src/result_screen.cpp
===================================================================
--- trunk/pingus/src/result_screen.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/result_screen.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -25,8 +25,8 @@
#include "resource.hpp"
#include "fonts.hpp"
#include "game_session.hpp"
-#include "system.hpp"
-#include "string_util.hpp"
+#include "util/system.hpp"
+#include "util/string_util.hpp"
#include "sound/sound.hpp"
#include "game_time.hpp"
#include "result_screen.hpp"
Modified: trunk/pingus/src/savegame.cpp
===================================================================
--- trunk/pingus/src/savegame.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/savegame.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -15,9 +15,10 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
-#include "sexpr_file_writer.hpp"
+
#include "savegame.hpp"
-#include "string_util.hpp"
+#include "util/sexpr_file_writer.hpp"
+#include "util/string_util.hpp"
std::string
Savegame::status_to_string(S_Status status)
Modified: trunk/pingus/src/savegame.hpp
===================================================================
--- trunk/pingus/src/savegame.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/savegame.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -18,8 +18,8 @@
#define HEADER_PINGUS_SAVEGAME_HPP
#include <string>
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
class SExprFileWriter;
Modified: trunk/pingus/src/savegame_manager.cpp
===================================================================
--- trunk/pingus/src/savegame_manager.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/savegame_manager.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -16,10 +16,11 @@
#include <assert.h>
#include <fstream>
-#include "system.hpp"
+
+#include "util/system.hpp"
#include "pingus_error.hpp"
-#include "sexpr_file_reader.hpp"
-#include "sexpr_file_writer.hpp"
+#include "util/sexpr_file_reader.hpp"
+#include "util/sexpr_file_writer.hpp"
#include "savegame_manager.hpp"
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
Modified: trunk/pingus/src/screenshot.cpp
===================================================================
--- trunk/pingus/src/screenshot.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/screenshot.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -23,7 +23,7 @@
#include "display/display.hpp"
#include "display/framebuffer.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "screenshot.hpp"
#include "gettext.h"
#include "png.h"
Modified: trunk/pingus/src/server.cpp
===================================================================
--- trunk/pingus/src/server.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/server.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -17,7 +17,8 @@
#include <time.h>
#include <iostream>
#include <fstream>
-#include "system.hpp"
+
+#include "util/system.hpp"
#include "pingu.hpp"
#include "globals.hpp"
#include "server.hpp"
Modified: trunk/pingus/src/server_event.cpp
===================================================================
--- trunk/pingus/src/server_event.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/server_event.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -24,7 +24,7 @@
#include "world.hpp"
#include "pingu_holder.hpp"
#include "pingu.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
ServerEvent::ServerEvent()
: type(PINGU_ACTION_EVENT),
Modified: trunk/pingus/src/server_event.hpp
===================================================================
--- trunk/pingus/src/server_event.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/server_event.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -18,7 +18,7 @@
#define HEADER_PINGUS_SERVER_EVENT_HPP
#include <iosfwd>
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "pingu_enums.hpp"
#include "math/vector3f.hpp"
Deleted: trunk/pingus/src/sexpr_file_reader.cpp
===================================================================
--- trunk/pingus/src/sexpr_file_reader.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/sexpr_file_reader.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -1,269 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <assert.h>
-#include "math/vector3f.hpp"
-#include "math/color.hpp"
-#include "math/rect.hpp"
-#include "math/size.hpp"
-#include "res_descriptor.hpp"
-#include "resource_modifier.hpp"
-#include "math/vector2i.hpp"
-#include "file_reader_impl.hpp"
-#include "sexpr_file_reader.hpp"
-
-class SExprFileReaderImpl: public FileReaderImpl
-{
-public:
- boost::shared_ptr<lisp::Lisp> sexpr;
-
- SExprFileReaderImpl(boost::shared_ptr<lisp::Lisp> sexpr_)
- : sexpr(sexpr_)
- {
- assert(sexpr->get_type() == lisp::Lisp::TYPE_LIST &&
- sexpr->get_list_size() >= 1);
-
- for(size_t i = 1; i < sexpr->get_list_size(); ++i)
- { // iterate over subsections
- sexpr->get_list_elem(i);
- }
- }
-
- ~SExprFileReaderImpl()
- {
- // FIXME: Do we have to free the lisp pointer here or outside of the code?
- }
-
- std::string get_name() const
- {
- return sexpr->get_list_elem(0)->get_symbol();
- }
-
- bool read_int (const char* name, int& v) const
- {
- boost::shared_ptr<lisp::Lisp> item = get_subsection_item(name);
- if (item && item->get_type() == lisp::Lisp::TYPE_INT)
- {
- v = item->get_int();
- return true;
- }
- return false;
- }
-
- bool read_float (const char* name, float& v) const
- {
- boost::shared_ptr<lisp::Lisp> item = get_subsection_item(name);
- if (item)
- {
- if (item->get_type() == lisp::Lisp::TYPE_FLOAT)
- {
- v = item->get_float();
- return true;
- }
- else if (item->get_type() == lisp::Lisp::TYPE_INT)
- {
- v = (float)item->get_int();
- return true;
- }
- else
- {
- return false;
- }
- }
- return false;
- }
-
- bool read_bool (const char* name, bool& v) const
- {
- boost::shared_ptr<lisp::Lisp> item = get_subsection_item(name);
- if (item && item->get_type() == lisp::Lisp::TYPE_BOOL)
- {
- v = item->get_bool();
- return true;
- }
- else if (item && item->get_type() == lisp::Lisp::TYPE_INT)
- {
- v = item->get_int();
- return true;
- }
- return false;
- }
-
- bool read_string(const char* name, std::string& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub)
- {
- v = "";
- for(size_t i = 1; i < sub->get_list_size(); ++i)
- {
- boost::shared_ptr<lisp::Lisp> item = sub->get_list_elem(i);
- if (item->get_type() == lisp::Lisp::TYPE_STRING)
- {
- v += item->get_string();
- }
- else if (item->get_type() == lisp::Lisp::TYPE_SYMBOL)
- {
- v += item->get_symbol();
- }
- }
- return true;
- }
- return false;
- }
-
- bool read_vector(const char* name, Vector3f& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 4)
- {
- v = Vector3f(sub->get_list_elem(1)->get_float(),
- sub->get_list_elem(2)->get_float(),
- sub->get_list_elem(3)->get_float());
- return true;
- }
- return false;
- }
-
- bool read_size(const char* name, Size& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 3)
- {
- v.width = sub->get_list_elem(1)->get_int();
- v.height = sub->get_list_elem(2)->get_int();
- return true;
- }
- return false;
- }
-
- bool read_vector2i(const char* name, Vector2i& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 3)
- {
- v.x = sub->get_list_elem(1)->get_int();
- v.y = sub->get_list_elem(2)->get_int();
- return true;
- }
- return false;
- }
-
- bool read_rect(const char* name, Rect& rect) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 5)
- {
- rect.left = sub->get_list_elem(1)->get_int();
- rect.top = sub->get_list_elem(2)->get_int();
- rect.right = sub->get_list_elem(3)->get_int();
- rect.bottom = sub->get_list_elem(4)->get_int();
- return true;
- }
- return false;
- }
-
- bool read_color (const char* name, Color& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 5)
- {
- v = Color(int(sub->get_list_elem(1)->get_float() * 255),
- int(sub->get_list_elem(2)->get_float() * 255),
- int(sub->get_list_elem(3)->get_float() * 255),
- int(sub->get_list_elem(4)->get_float() * 255));
- return true;
- }
- return false;
- }
-
- bool read_desc (const char* name, ResDescriptor& v) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub)
- {
- SExprFileReader reader(sub);
- reader.read_string("image", v.res_name);
- reader.read_enum("modifier", v.modifier,
ResourceModifierNS::rs_from_string);
- return true;
- }
- return false;
- }
-
- bool read_section(const char* name, FileReader& v) const
- {
- boost::shared_ptr<lisp::Lisp> cur = get_subsection(name);
- if (cur)
- {
- v = SExprFileReader(cur);
- return true;
- }
- return false;
- }
-
- std::vector<FileReader> get_sections() const
- {
- std::vector<FileReader> lst;
- for(size_t i = 1; i < sexpr->get_list_size(); ++i)
- { // iterate over subsections
- lst.push_back(SExprFileReader(sexpr->get_list_elem(i)));
- }
- return lst;
- }
-
- std::vector<std::string> get_section_names() const
- {
- std::vector<std::string> lst;
-
- for(size_t i = 1; i < sexpr->get_list_size(); ++i)
- { // iterate over subsections
- boost::shared_ptr<lisp::Lisp> sub = sexpr->get_list_elem(i);
- lst.push_back(sub->get_list_elem(0)->get_symbol());
- }
-
- return lst;
- }
-
-private:
- boost::shared_ptr<lisp::Lisp> get_subsection_item(const char* name) const
- {
- boost::shared_ptr<lisp::Lisp> sub = get_subsection(name);
- if (sub && sub->get_list_size() == 2)
- {
- return sub->get_list_elem(1);
- }
- return boost::shared_ptr<lisp::Lisp>();
- }
-
- boost::shared_ptr<lisp::Lisp> get_subsection(const char* name) const
- {
- for(size_t i = 1; i < sexpr->get_list_size(); ++i)
- { // iterate over subsections
- boost::shared_ptr<lisp::Lisp> sub = sexpr->get_list_elem(i);
- if (strcmp(sub->get_list_elem(0)->get_symbol(), name) == 0)
- return sub;
- }
- return boost::shared_ptr<lisp::Lisp>();
- }
-
-};
-
-SExprFileReader::SExprFileReader(boost::shared_ptr<lisp::Lisp> lisp)
- : FileReader(boost::shared_ptr<FileReaderImpl>(new
SExprFileReaderImpl(lisp)))
-{
-}
-
-/* EOF */
Deleted: trunk/pingus/src/sexpr_file_reader.hpp
===================================================================
--- trunk/pingus/src/sexpr_file_reader.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/sexpr_file_reader.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -1,33 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SEXPR_FILE_READER_HPP
-#define HEADER_SEXPR_FILE_READER_HPP
-
-#include "file_reader.hpp"
-#include "lisp/lisp.hpp"
-
-/** */
-class SExprFileReader : public FileReader
-{
-private:
-public:
- SExprFileReader(boost::shared_ptr<lisp::Lisp> lisp);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/sexpr_file_writer.cpp
===================================================================
--- trunk/pingus/src/sexpr_file_writer.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/sexpr_file_writer.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -1,117 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 Jimmy Salmon
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <iostream>
-#include <string>
-#include <map>
-#include "sexpr_file_writer.hpp"
-
-SExprFileWriter::SExprFileWriter(std::ostream& out_)
- : out(&out_), level(0)
-{
-}
-
-SExprFileWriter::~SExprFileWriter()
-{
-}
-
-std::string
-SExprFileWriter::indent()
-{
- return std::string(level*2, ' ');
-}
-
-void
-SExprFileWriter::begin_section(const char* name)
-{
- (*out) << "\n" << indent() << "(" << name << " ";
- ++level;
-}
-
-void
-SExprFileWriter::end_section()
-{
- --level;
- (*out) << ")";
-}
-
-void
-SExprFileWriter::write_int(const char* name, int value)
-{
- (*out) << "\n" << indent() << "(" << name << " " << value << ")";
-}
-
-void
-SExprFileWriter::write_float(const char* name, float value)
-{
- (*out) << "\n" << indent() << "(" << name << " " << value << ")";
-}
-
-void
-SExprFileWriter::write_color(const char* name, const Color& color)
-{
- (*out) << "\n" << indent() << "(" << name << " "
- << color.r/255.0f << " "
- << color.g/255.0f << " "
- << color.b/255.0f << " "
- << color.a/255.0f << ")";
-}
-
-void
-SExprFileWriter::write_bool(const char* name, bool value)
-{
- (*out) << "\n" << indent() << "(" << name << " " << (value ? "#t" : "#f") <<
")";
-}
-
-void
-SExprFileWriter::write_string(const char* name, const std::string& value)
-{
- // Perform basic XML encoding (turns apostrophes into ', etc.
- std::string new_value = value;
- std::string::size_type pos;
-
- std::map<std::string, std::string> replacements;
-
- replacements["\""] = "\\\"";
- replacements["\\"] = "\\\\";
-
- for (std::map<std::string, std::string>::iterator i =
replacements.begin();
- i != replacements.end(); i++)
- {
- for (pos = new_value.find(i->first); pos != std::string::npos;
pos = new_value.find(i->first))
- {
- // Replace character with encoding characters
- new_value.replace(pos, 1, i->second);
- }
- }
-
- (*out) << "\n" << indent() << "(" << name << " \"" << new_value <<
"\")";
-}
-
-void
-SExprFileWriter::write_vector(const char* name, const Vector3f& value)
-{
- (*out) << "\n" << indent() << "(" << name << " "
- << value.x << " " << value.y << " " << value.z << ")";
-}
-
-void
-SExprFileWriter::write_size(const char* name, const Size& size)
-{
- (*out) << "\n" << indent() << "(" << name << " " << size.width << " " <<
size.height << ")";
-}
-
-/* EOF */
Deleted: trunk/pingus/src/sexpr_file_writer.hpp
===================================================================
--- trunk/pingus/src/sexpr_file_writer.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/sexpr_file_writer.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -1,63 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 Jimmy Salmon
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_SEXPR_FILE_WRITER_HPP
-#define HEADER_SEXPR_FILE_WRITER_HPP
-
-#include <iosfwd>
-#include "file_writer.hpp"
-#include "math/color.hpp"
-#include "math/vector3f.hpp"
-#include "math/size.hpp"
-
-/** */
-class SExprFileWriter : public FileWriter
-{
-private:
- /** A reference to the output stream */
- std::ostream* out;
- int level;
- std::string indent();
-
-public:
- SExprFileWriter(std::ostream& out_);
- virtual ~SExprFileWriter();
-
- virtual void begin_section(const char* name);
- virtual void end_section();
-
- virtual void write_int(const char* name, int);
- virtual void write_float(const char* name, float);
- virtual void write_color(const char* name, const Color&);
- virtual void write_bool(const char* name, bool);
- virtual void write_string(const char* name, const std::string&);
- virtual void write_vector(const char* name, const Vector3f&);
- virtual void write_size(const char* name, const Size&);
-
- template<class E, class F>
- void write_enum(const char* name, E value, F enum2string)
- {
- (*out) << "\n" << indent() << "(" << name << " \"" << enum2string(value)
<< "\")";
- }
-
-private:
- SExprFileWriter(const SExprFileWriter&);
- SExprFileWriter& operator= (const SExprFileWriter&);
-};
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/sprite_description.hpp
===================================================================
--- trunk/pingus/src/sprite_description.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/sprite_description.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -21,7 +21,7 @@
#include "math/vector2i.hpp"
#include "math/size.hpp"
#include "math/origin.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "pathname.hpp"
/** */
Modified: trunk/pingus/src/start_screen.cpp
===================================================================
--- trunk/pingus/src/start_screen.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/start_screen.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -23,7 +23,7 @@
#include "gettext.h"
#include "game_session.hpp"
#include "globals.hpp"
-#include "system.hpp"
+#include "util/system.hpp"
#include "fonts.hpp"
#include "resource.hpp"
#include "start_screen.hpp"
@@ -32,7 +32,7 @@
#include "pingus_level.hpp"
#include "string_format.hpp"
#include "display/display.hpp"
-#include "string_util.hpp"
+#include "util/string_util.hpp"
class StartScreenComponent : public GUI::Component
{
Modified: trunk/pingus/src/stat_manager.cpp
===================================================================
--- trunk/pingus/src/stat_manager.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/stat_manager.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,14 +16,15 @@
#include <algorithm>
#include <fstream>
-#include "system.hpp"
+
+#include "lisp/lisp.hpp"
+#include "lisp/parser.hpp"
#include "pingus_error.hpp"
-#include "string_util.hpp"
#include "stat_manager.hpp"
-#include "sexpr_file_reader.hpp"
-#include "sexpr_file_writer.hpp"
-#include "lisp/lisp.hpp"
-#include "lisp/parser.hpp"
+#include "util/sexpr_file_reader.hpp"
+#include "util/sexpr_file_writer.hpp"
+#include "util/string_util.hpp"
+#include "util/system.hpp"
StatManager* StatManager::instance_ = 0;
Modified: trunk/pingus/src/story_screen.cpp
===================================================================
--- trunk/pingus/src/story_screen.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/story_screen.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -33,7 +33,7 @@
#include "stat_manager.hpp"
#include "credits.hpp"
#include "display/display.hpp"
-#include "utf8.hpp"
+#include "util/utf8.hpp"
#include "sound/sound.hpp"
class StoryScreenComponent : public GUI::Component
Modified: trunk/pingus/src/string_format.cpp
===================================================================
--- trunk/pingus/src/string_format.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/string_format.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -15,9 +15,10 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <sstream>
+
#include "font.hpp"
#include "string_format.hpp"
-#include "utf8.hpp"
+#include "util/utf8.hpp"
std::string
StringFormat::normalize(std::string text)
Deleted: trunk/pingus/src/string_util.cpp
===================================================================
--- trunk/pingus/src/string_util.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/string_util.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,51 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include "string_util.hpp"
-
-// Code based on clanstring.cpp from ClanLib 0.8
-
-std::string
-StringUtil::to_lower(const std::string &str)
-{
- std::string lower_impl = str;
-
- for( std::string::iterator i = lower_impl.begin();
- i != lower_impl.end();
- ++i )
- {
- *i = tolower(*i);
- }
-
- return lower_impl;
-}
-
-std::string
-StringUtil::to_upper(const std::string &str)
-{
- std::string upper_impl = str;
-
- for( std::string::iterator i = upper_impl.begin();
- i != upper_impl.end();
- ++i )
- {
- *i = toupper(*i);
- }
-
- return upper_impl;
-}
-
-/* EOF */
Deleted: trunk/pingus/src/string_util.hpp
===================================================================
--- trunk/pingus/src/string_util.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/string_util.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,89 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_STRING_UTIL_HPP
-#define HEADER_STRING_UTIL_HPP
-
-#include <sstream>
-
-/** */
-class StringUtil
-{
-private:
-public:
- static std::string to_lower(const std::string &str);
- static std::string to_upper(const std::string &str);
-
- template<class T>
- static T to(const std::string& s, const T& val = T())
- {
- T tmp = val;
- std::istringstream str(s);
- str >> tmp;
- return tmp;
- }
-
- template<class T>
- static bool from_string(const std::string& s, T& t)
- {
- std::istringstream str(s);
- T tmp;
- str >> tmp;
- if (str.fail())
- {
- return false;
- }
- else
- {
- t = tmp;
- return true;
- }
- return false;
- }
-
- template<class T>
- static std::string to_string(const T& t)
- {
- std::ostringstream str;
- str << t;
- return str.str();
- }
-
- static bool has_suffix(const std::string& str, const std::string& suffix)
- {
- if (str.length() >= suffix.length())
- return str.compare(str.length() - suffix.length(), suffix.length(),
suffix) == 0;
- else
- return false;
- }
-
- static bool has_prefix(const std::string& str, const std::string prefix)
- {
- if (str.length() < prefix.length())
- return false;
- else
- return str.compare(0, prefix.length(), prefix) == 0;
- }
-
-private:
- StringUtil ();
- StringUtil (const StringUtil&);
- StringUtil& operator= (const StringUtil&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/system.cpp
===================================================================
--- trunk/pingus/src/system.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/system.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,500 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <locale.h>
-
-#ifndef WIN32
-# include <dirent.h>
-# include <fcntl.h>
-# include <fnmatch.h>
-# include <sys/stat.h>
-# include <sys/types.h>
-# include <unistd.h>
-# include <errno.h>
-#else /* WIN32 */
-# include <windows.h>
-# include <direct.h>
-# include <fstream>
-# include <sys/stat.h>
-# include <sys/types.h>
-# include <io.h>
-#define chdir _chdir
-#define access _access
-#define F_OK 0
-#endif
-
-#include <config.h>
-#include <iostream>
-#include <sstream>
-
-#include "pathname.hpp"
-#include "pingus_error.hpp"
-#include "globals.hpp"
-#include "system.hpp"
-#include "string_util.hpp"
-#include "gettext.h"
-
-std::string System::userdir;
-std::string System::default_email;
-std::string System::default_username;
-
-System::DirectoryEntry::DirectoryEntry(const std::string& n, FileType t)
- : type (t), name (n)
-{
-}
-
-System::Directory
-System::opendir(const std::string& pathname, const std::string& pattern)
-{
- Directory dir_list;
-
-#ifndef WIN32
- DIR* dp;
- dirent* de;
-
- dp = ::opendir(pathname.c_str());
-
- if (dp == 0)
- {
- std::cout << "System: Couldn't open: " << pathname << std::endl;
- }
- else
- {
- while ((de = ::readdir(dp)) != 0)
- {
- if (fnmatch(pattern.c_str(), de->d_name, FNM_PATHNAME) == 0)
- {
- struct stat buf;
- stat ((pathname + "/" + de->d_name).c_str (), &buf);
-
- if (S_ISDIR(buf.st_mode))
- {
- dir_list.push_back(DirectoryEntry(de->d_name, DE_DIRECTORY));
- }
- else
- {
- dir_list.push_back(DirectoryEntry(de->d_name, DE_FILE));
- }
- }
- }
-
- closedir(dp);
- }
-#else /* WIN32 */
- WIN32_FIND_DATA coFindData;
- std::string FindFileDir = pathname + "/" + pattern;
- HANDLE hFind = FindFirstFile(TEXT(FindFileDir.c_str()),&coFindData);
-
- if (hFind == INVALID_HANDLE_VALUE)
- {
- if (GetLastError() != ERROR_FILE_NOT_FOUND)
- std::cout << "System: Couldn't open: " << pathname << std::endl;
- }
- else
- {
- do
- {
- if (coFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- dir_list.push_back(DirectoryEntry(coFindData.cFileName,
System::DE_DIRECTORY));
- }
- else
- {
- dir_list.push_back(DirectoryEntry(coFindData.cFileName,
System::DE_FILE));
- }
- }
- while (FindNextFile(hFind,&coFindData));
-
- FindClose(hFind);
- }
-#endif
-
- return dir_list;
-}
-
-// Returns the basic filename without the path
-std::string
-System::basename(std::string filename)
-{
- // Should be replaced with STL
- const char* str = filename.c_str();
- int i;
-
- for(i = (int)filename.size() - 1; i >= 0; --i)
- {
- if (*(str + i) == '/') {
- break;
- }
- }
-
- return (str+i + 1);
-}
-
-std::string
-System::dirname (std::string filename)
-{
- const char* str = filename.c_str();
- int i;
-
- for(i = (int)filename.size() - 1; i >= 0; --i)
- {
- if (*(str + i) == '/') {
- break;
- }
- }
-
- return filename.substr(0, i);
-}
-
-bool
-System::exist(std::string filename)
-{
- return !access(filename.c_str(), F_OK);
-}
-
-void
-System::create_dir(std::string directory)
-{
-#ifndef WIN32
- if (pingus_debug_flags & PINGUS_DEBUG_DIRECTORIES)
- {
- std::cout << "System::create_dir: " << directory << std::endl;
- }
-
- if (!exist(directory))
- {
- if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IXGRP) != 0)
- {
- throw PingusError("System::create_dir: " + directory + ": " +
strerror(errno));
- }
- else
- {
- std::cout << "Successfully created: " << directory << std::endl;
- }
- }
-#else
- if (!CreateDirectory(directory.c_str(), 0))
- {
- DWORD dwError = GetLastError();
- if (dwError == ERROR_ALREADY_EXISTS)
- {
- }
- else if (dwError == ERROR_PATH_NOT_FOUND)
- {
- throw PingusError("CreateDirectory: " + directory +
- ": One or more intermediate directories do not exist; this
function will only create the final directory in the path.");
- }
- else
- {
- throw PingusError("CreateDirectory: " + directory + ": failed with
error " + StringUtil::to_string(dwError));
- }
- }
- else
- {
- std::cout << "Successfully created: " << directory << std::endl;
- }
-#endif
-}
-
-std::string
-System::find_userdir()
-{
-#ifdef WIN32
- std::string tmpstr;
- char* appdata = getenv("APPDATA");
- if (appdata)
- {
- tmpstr = std::string(appdata) + "/Pingus/";
- for (size_t pos = tmpstr.find('\\', 0); pos != std::string::npos; pos =
tmpstr.find('\\', 0))
- tmpstr[pos] = '/';
- }
- else
- {
- tmpstr = "user/";
- }
-
- return tmpstr;
-
-#else /* !WIN32 */
- char* homedir = getenv("HOME");
-
- if (homedir)
- {
- return std::string(homedir) + "/.pingus/";
- }
- else
- {
- throw PingusError("Environment variable $HOME not set, fix that and
start again.");
- }
-#endif
-}
-
-void
-System::init_directories()
-{
- if (userdir.empty())
- userdir = find_userdir();
-
- std::string statdir = get_userdir();
-
- create_dir(statdir);
-
- // FIXME: We need a better seperation between user created levels,
- // FIXME: third party levels and levels from the base distri
- create_dir(statdir + "levels/");
- create_dir(statdir + "levels/dist");
- create_dir(statdir + "themes/");
-
- // Savegames (FIXME: rename to savegames/?)
- create_dir(statdir + "savegames/");
-
- // User created images
- create_dir(statdir + "images/");
-
- // Thumbnail cache
- create_dir(statdir + "cache/");
-
- // Recorded demos will per default be writen in this directory
- create_dir(statdir + "demos/");
-
- // User created images
- create_dir(statdir + "backup/");
-
- // Screenshots will be dumped to that directory:
- create_dir(statdir + "screenshots/");
-}
-
-void
-System::set_userdir(const std::string& u)
-{
- userdir = u + "/";
-}
-
-std::string
-System::get_userdir()
-{
- return userdir;
-}
-
-std::string
-System::get_cachedir()
-{
- return get_userdir() + "cache/";
-}
-
-/** Returns the username of the current user or an empty string */
-std::string
-System::get_username()
-{
- if (default_username.empty())
- {
- char* username = getenv("USERNAME");
-
- if (username)
- return std::string(username);
- else
- return "";
- }
- else
- {
- return default_username;
- }
-}
-
-/** Returns the EMail of the user or an empty string */
-std::string
-System::get_email()
-{
- if (default_email.empty())
- {
- char* email = getenv("EMAIL");
-
- if (email)
- // FIXME: $EMAIL contains the complete from header, not only
- // the email address
- return std::string(email);
- else
- return "";
- }
- else
- {
- return default_email;
- }
-}
-
-std::string
-System::get_language()
-{
-#ifdef WIN32
- char* lang_c = getenv("LC_MESSAGES");
-#else
- char* lang_c = setlocale(LC_MESSAGES, NULL);
-#endif
-
- std::string lang;
-
- if (lang_c)
- lang = lang_c;
-
- if (lang.empty() || lang == "C")
- return default_language;
- else
- return lang.substr(0, 2);
-}
-
-std::string
-System::checksum(const Pathname& pathname)
-{
- return checksum(pathname.get_sys_path());
-}
-
-/** Read file and create a checksum and return it */
-std::string
-System::checksum(std::string filename)
-{ // FIXME: Replace sys with SHA1 or MD5 or so
- FILE* in;
- size_t bytes_read;
- char buffer[4096];
- long int checksum = 0;
-
- in = fopen(filename.c_str(), "r");
-
- if (!in)
- {
- std::cout << "System::checksum: Couldn't open file: " << filename <<
std::endl;
- return "";
- }
-
- do
- {
- bytes_read = fread(buffer, sizeof (char), 4096, in);
-
- if (bytes_read != 4096 && !feof(in))
- {
- throw PingusError("System:checksum: file read error");
- }
-
- for (size_t i=0; i < bytes_read; ++i)
- checksum = checksum * 17 + buffer[i];
- }
- while (bytes_read != 0);
-
- fclose (in);
-
- std::ostringstream str;
- str << checksum;
- return str.str();
-}
-
-
-uint64_t
-System::get_mtime(const std::string& filename)
-{
-#ifndef WIN32
-
- struct stat stat_buf;
- if (stat(filename.c_str(), &stat_buf) == 0)
- return stat_buf.st_mtime;
- else
- return 0;
-
-#else
-
- struct _stat stat_buf;
- if (_stat(filename.c_str(), &stat_buf) == 0)
- return stat_buf.st_mtime;
- else
- return 0;
-
-#endif
-}
-
-std::string
-System::realpath(const std::string& pathname)
-{
- std::string fullpath;
- std::string drive;
-
- if (pathname.size() > 0 && pathname[0] == '/')
- {
- fullpath = pathname;
- }
-#ifdef WIN32
- else if (pathname.size() > 2 && pathname[1] == ':' && pathname[2] == '/')
- {
- drive = pathname.substr(0, 2);
- fullpath = pathname;
- }
-#endif
- else
- {
- char buf[PATH_MAX];
- if (getcwd(buf, PATH_MAX) == 0)
- {
- std::cout << "System::realpath: Error: couldn't getcwd()" <<
std::endl;
- return pathname;
- }
-#ifdef WIN32
- for (char *p = buf; *p; ++p)
- {
- if (*p == '\\')
- *p = '/';
- }
- drive.assign(buf, 2);
-#endif
-
- fullpath = fullpath + buf + "/" + pathname;
- }
-
- std::string result;
- std::string::reverse_iterator last_slash = fullpath.rbegin();
- int skip = 0;
- // /foo/bar/../../bar/baz/
- //std::cout << "fullpath: '" << fullpath << "'" << std::endl;
- for(std::string::reverse_iterator i = fullpath.rbegin(); i !=
fullpath.rend(); ++i)
- { // FIXME: Little crude and hackish
- if (*i == '/')
- {
- std::string dir(last_slash, i);
- //std::cout << "'" << dir << "'" << std::endl;
- if (dir == ".." || dir == "/..")
- {
- skip += 1;
- }
- else if (dir == "." || dir == "/." || dir.empty() || dir == "/")
- {
- // pass
- }
- else
- {
- if (skip == 0)
- {
- result += dir;
- }
- else
- skip -= 1;
- }
-
- last_slash = i;
- }
- }
-
- return drive + "/" + std::string(result.rbegin(), result.rend());
-}
-
-/* EOF */
Deleted: trunk/pingus/src/system.hpp
===================================================================
--- trunk/pingus/src/system.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/system.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,118 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_SYSTEM_HPP
-#define HEADER_PINGUS_SYSTEM_HPP
-
-#include "pingus.hpp"
-#include <string>
-#include <vector>
-#include <map>
-#include "SDL.h"
-
-class Pathname;
-
-/** A wrapper class around some system dependend functions (mostly
- POSIX stuff) */
-class System
-{
-private:
- static std::string default_email;
- static std::string default_username;
-
- static std::string userdir;
-
-public:
- enum FileType { DE_DIRECTORY, DE_FILE };
-
- struct DirectoryEntry
- {
- FileType type;
- std::string name;
-
- DirectoryEntry(const std::string&, FileType t = DE_FILE);
- };
-
- ///
- typedef std::vector<DirectoryEntry> Directory;
- typedef Directory::iterator DirectoryIter;
-
- ///
- static Directory opendir(const std::string& pathname, const std::string&
pattern = "*");
-
- /** Check if a file is avaiblable (no checking for permissens is currently
performed)
- @param filename The name of the file
- @return True, if the file exist, false otherwise */
- static bool exist(std::string filename);
-
- /** Creates directory if it does not already exist.
- @param dir The name of the directory */
- static void create_dir(std::string dir);
-
- /** Check if all needed directories are available, if not then create
- them. */
- static void init_directories();
-
- /** Strips directory from filenames
- @param filename The complete filename */
- static std::string basename(std::string filename);
-
- /** Strips basename from pathnames (see dirname(3))
- @param filename The complete filename */
- static std::string dirname(std::string filename);
-
- static std::string find_userdir();
-
- /** Sets the directory to save users data to */
- static void set_userdir(const std::string&);
-
- /** Returns the directory where Pingus can store its user specific
- state and config data (savegames, config files, demos, etc.) */
- static std::string get_userdir();
-
- /** Returns the directory where Pingus can store things that needs
- to be cached, for example thumbnails */
- static std::string get_cachedir();
-
- /** Returns the Username how the current user or an empty string */
- static std::string get_username();
-
- /** Returns the EMail of the user or an empty string */
- static std::string get_email();
-
- /** Get the currently country code, in a two letter ISO 639 syntax */
- static std::string get_language();
-
- /** Return the modification time of a file */
- static uint64_t get_mtime(const std::string& filename);
-
- /** Removes all .., double slashes and such from a pathname */
- static std::string realpath(const std::string& pathname);
-
- /** Read a file and generate a checksum and return it. The checksum
- generation is very primitiv and should probably be replaced by CRC
- or md5. */
- static std::string checksum (std::string filename);
- static std::string checksum (const Pathname& pathname);
-private:
- System (const System&);
- System& operator= (const System&);
-};
-
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/utf8.cpp
===================================================================
--- trunk/pingus/src/utf8.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/utf8.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,254 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2008 Matthias Braun <address@hidden>,
-// Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#include <iostream>
-#include <stdexcept>
-#include "utf8.hpp"
-
-/** Replacement character for invalid UTF-8 sequences */
-static const uint32_t INVALID_UTF8_SEQUENCE = 0xFFFD;
-
-bool
-UTF8::is_linebreak_character(uint32_t unicode)
-{
- if (unicode == ' ' || unicode >= 0x3400)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-std::string::size_type
-UTF8::length(const std::string& str)
-{
- // Not checking for valid UTF-8 sequences should be ok, since
- // incorrect ones are a character too.
- std::string::size_type len = 0;
- for(std::string::const_iterator i = str.begin(); i != str.end(); ++i)
- {
- unsigned char c = *i;
- if (((c & 0xc0) == 0xc0) || (c < 0x80)) // 0xc0 == 1100_000
- {
- len += 1;
- }
- }
-
- return len;
-}
-
-std::string
-UTF8::substr(const iterator& first, const iterator& last)
-{
- return first.get_string().substr(first.get_index(),
- last.get_index() - first.get_index());
-}
-
-std::string
-UTF8::substr(const std::string& text, std::string::size_type pos,
std::string::size_type n)
-{
- std::string::const_iterator beg_it = UTF8::advance(text.begin(), pos);
- std::string::const_iterator end_it = UTF8::advance(beg_it, n);
-
- return std::string(beg_it, end_it);
-}
-
-std::string::const_iterator
-UTF8::advance(std::string::const_iterator it, std::string::size_type n)
-{
- for(std::string::size_type i = 0; i < n; ++i)
- {
- // FIXME: Doesn't check if UTF8 sequence is valid
- unsigned char c = *it;
-
- if (c < 0x80)
- {
- it += 1;
- }
- else if ((c & 0xf0) == 0xf0)
- {
- it += 4;
- }
- else if ((c & 0xe0) == 0xe0)
- {
- it += 3;
- }
- else if ((c & 0xc0) == 0xc0)
- {
- it += 2;
- }
- else
- {
- std::cout << "UTF8: malformed UTF-8 sequence: " << (int)c <<
std::endl;
- it += 1;
- }
- }
-
- return it;
-}
-/**
- * returns true if this byte matches a bitmask of 10xx.xxxx, i.e. it is the
2nd, 3rd or 4th byte of a multibyte utf8 string
- */
-bool
-UTF8::has_multibyte_mark(unsigned char c)
-{
- return ((c & 0300) == 0200);
-}
-
-uint32_t
-UTF8::decode_utf8(const std::string& text)
-{
- size_t p = 0;
- return decode_utf8(text, p);
-}
-
-/**
- * gets unicode character at byte position @a p of UTF-8 encoded @a
- * text, then advances @a p to the next character.
- *
- * @throws std::runtime_error if decoding fails.
- * See unicode standard section 3.10 table 3-5 and 3-6 for details.
- */
-uint32_t
-UTF8::decode_utf8(const std::string& text, size_t& p)
-{
- uint32_t c1 = (unsigned char) text[p+0];
-
- if (has_multibyte_mark(c1))
- {
- throw std::runtime_error("Malformed utf-8 sequence");
- }
- else if ((c1 & 0200) == 0000)
- {
- // 0xxx.xxxx: 1 byte sequence
- p+=1;
-
- return c1;
- }
- else if ((c1 & 0340) == 0300)
- {
- // 110x.xxxx: 2 byte sequence
- if(p+1 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = (unsigned char) text[p+1];
- if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
- p+=2;
-
- return (c1 & 0037) << 6 | (c2 & 0077);
- }
- else if ((c1 & 0360) == 0340)
- {
- // 1110.xxxx: 3 byte sequence
- if(p+2 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = (unsigned char) text[p+1];
- uint32_t c3 = (unsigned char) text[p+2];
- if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
- if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8
sequence");
- p+=3;
-
- return (c1 & 0017) << 12 | (c2 & 0077) << 6 | (c3 & 0077);
- }
- else if ((c1 & 0370) == 0360)
- {
- // 1111.0xxx: 4 byte sequence
- if(p+3 >= text.size()) throw std::range_error("Malformed utf-8
sequence");
- uint32_t c2 = (unsigned char) text[p+1];
- uint32_t c3 = (unsigned char) text[p+2];
- uint32_t c4 = (unsigned char) text[p+4];
- if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8
sequence");
- if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8
sequence");
- if (!has_multibyte_mark(c4)) throw std::runtime_error("Malformed utf-8
sequence");
- p+=4;
-
- return (c1 & 0007) << 18 | (c2 & 0077) << 12 | (c3 & 0077) << 6 | (c4 &
0077);
- }
- else
- {
- throw std::runtime_error("Malformed utf-8 sequence");
- }
-}
-
-// FIXME: Get rid of exceptions in this code
-UTF8::iterator::iterator(const std::string& text_)
- : text(&text_),
- pos(0),
- idx(0),
- chr(INVALID_UTF8_SEQUENCE)
-{
-}
-
-UTF8::iterator::iterator(const std::string& text_, const std::string::iterator
it)
- : text(&text_),
- pos(it - text->begin()),
- idx(pos),
- chr(INVALID_UTF8_SEQUENCE)
-{
-}
-
-UTF8::iterator
-UTF8::iterator::operator+(int n)
-{
- UTF8::iterator it = *this;
- for(int i = 0; i < n && it.next(); ++i);
- return it;
-}
-
-bool
-UTF8::iterator::next()
-{
- try
- {
- idx = pos;
- chr = decode_utf8(*text, pos);
- }
- catch (std::exception)
- {
- std::cout << "Malformed utf-8 sequence beginning with " <<
*((uint32_t*)(text->c_str() + pos)) << " found " << std::endl;
- chr = INVALID_UTF8_SEQUENCE;
- ++pos;
- }
-
- return pos <= text->size();
-}
-
-uint32_t
-UTF8::iterator::operator*() const
-{
- return chr;
-}
-
-#ifdef __TEST__
-int main(int argc, char** argv)
-{
- if (argc != 2)
- {
- std::cout << "Usage: " << argv[0] << " TEXT" << std::endl;
- }
- else
- {
- std::cout << "ASCII: " << std::string(argv[1]).length() << std::endl;
- std::cout << "UTF8: " << UTF8::length(argv[1]) << std::endl;
-
- std::string res = UTF8::substr(argv[1], 1, 1);
- std::cout << "substr: " << res.length() << " " << res << std::endl;
- }
- return 0;
-}
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/utf8.hpp
===================================================================
--- trunk/pingus/src/utf8.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/utf8.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -1,91 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2008 Matthias Braun <address@hidden>,
-// Ingo Ruhnke <address@hidden>
-//
-// This program 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 3 of the License, or
-// (at your option) any later version.
-//
-// This program 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.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_UTF8_HPP
-#define HEADER_PINGUS_UTF8_HPP
-
-#include <stdint.h>
-#include <string>
-
-class UTF8
-{
-public:
- class iterator
- {
- private:
- const std::string* text;
-
- /** Position of the next Unicode character after \a chr */
- std::string::size_type pos;
-
- /** Position of \a chr */
- std::string::size_type idx;
-
- /** Current Unicode character */
- uint32_t chr;
-
- public:
- /** Create a UTF8 iterator, note that \a text is stored as
- pointer, thus it must remain valid for the lifetime of the
- iterator. */
- iterator(const std::string& text);
- iterator(const std::string& text, std::string::iterator it);
-
- bool next();
- iterator operator+(int n);
- uint32_t operator*() const;
-
- /** Returns the starting position of the current character */
- std::string::size_type get_index() const { return idx; }
-
- const std::string& get_string() const { return *text; }
- };
-
- /**
- * Returns the number of characters in a UTF-8 string
- */
- static std::string::size_type length(const std::string& str);
-
- static std::string substr(const iterator& first, const iterator& last);
- static std::string substr(const std::string& text, std::string::size_type
pos, std::string::size_type n);
- static std::string::const_iterator advance(std::string::const_iterator it,
std::string::size_type n = 1);
-
- /**
- * return true if a linebreak is allowed after this character
- */
- static bool is_linebreak_character(uint32_t unicode);
-
- /**
- * returns true if this byte matches a bitmask of 10xx.xxxx, i.e. it is the
2nd, 3rd or 4th byte of a multibyte utf8 string
- */
- static bool has_multibyte_mark(unsigned char c);
-
- /**
- * gets unicode character at byte position @a p of UTF-8 encoded @a
- * text, then advances @a p to the next character.
- *
- * @throws std::runtime_error if decoding fails.
- * See unicode standard section 3.10 table 3-5 and 3-6 for details.
- */
- static uint32_t decode_utf8(const std::string& text, size_t& p);
-
- static uint32_t decode_utf8(const std::string& text);
-};
-
-#endif
-
-/* EOF */
Copied: trunk/pingus/src/util/debug_stream.cpp (from rev 4002,
trunk/pingus/src/debug_stream.cpp)
Copied: trunk/pingus/src/util/debug_stream.hpp (from rev 4002,
trunk/pingus/src/debug_stream.hpp)
Copied: trunk/pingus/src/util/file_reader.cpp (from rev 4002,
trunk/pingus/src/file_reader.cpp)
Copied: trunk/pingus/src/util/file_reader.hpp (from rev 4002,
trunk/pingus/src/file_reader.hpp)
Copied: trunk/pingus/src/util/file_reader_impl.hpp (from rev 4002,
trunk/pingus/src/file_reader_impl.hpp)
Copied: trunk/pingus/src/util/file_writer.hpp (from rev 4002,
trunk/pingus/src/file_writer.hpp)
Copied: trunk/pingus/src/util/sexpr_file_reader.cpp (from rev 4002,
trunk/pingus/src/sexpr_file_reader.cpp)
Copied: trunk/pingus/src/util/sexpr_file_reader.hpp (from rev 4002,
trunk/pingus/src/sexpr_file_reader.hpp)
Copied: trunk/pingus/src/util/sexpr_file_writer.cpp (from rev 4002,
trunk/pingus/src/sexpr_file_writer.cpp)
Copied: trunk/pingus/src/util/sexpr_file_writer.hpp (from rev 4002,
trunk/pingus/src/sexpr_file_writer.hpp)
Copied: trunk/pingus/src/util/string_util.cpp (from rev 4002,
trunk/pingus/src/string_util.cpp)
Copied: trunk/pingus/src/util/string_util.hpp (from rev 4002,
trunk/pingus/src/string_util.hpp)
Copied: trunk/pingus/src/util/system.cpp (from rev 4002,
trunk/pingus/src/system.cpp)
Copied: trunk/pingus/src/util/system.hpp (from rev 4002,
trunk/pingus/src/system.hpp)
Copied: trunk/pingus/src/util/utf8.cpp (from rev 4002,
trunk/pingus/src/utf8.cpp)
Copied: trunk/pingus/src/util/utf8.hpp (from rev 4002,
trunk/pingus/src/utf8.hpp)
Modified: trunk/pingus/src/worldmap/dot.cpp
===================================================================
--- trunk/pingus/src/worldmap/dot.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/worldmap/dot.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -16,7 +16,7 @@
#include <iostream>
#include <assert.h>
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "dot.hpp"
namespace WorldmapNS {
Modified: trunk/pingus/src/worldmap/drawable.hpp
===================================================================
--- trunk/pingus/src/worldmap/drawable.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldmap/drawable.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -18,7 +18,7 @@
#define HEADER_PINGUS_DRAWABLE_HPP
#include "../pingus_error.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
class DrawingContext;
Modified: trunk/pingus/src/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/worldmap/level_dot.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldmap/level_dot.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -18,7 +18,7 @@
#include "../font.hpp"
#include "../gettext.h"
#include "../globals.hpp"
-#include "../system.hpp"
+#include "util/system.hpp"
#include "../fonts.hpp"
#include "../display/drawing_context.hpp"
#include "../screen/screen_manager.hpp"
@@ -27,7 +27,7 @@
#include "../start_screen.hpp"
#include "../plf_res_mgr.hpp"
#include "../savegame_manager.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "input/controller.hpp"
#include "input/control.hpp"
#include "level_dot.hpp"
Modified: trunk/pingus/src/worldmap/path_graph.cpp
===================================================================
--- trunk/pingus/src/worldmap/path_graph.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldmap/path_graph.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -16,7 +16,7 @@
#include <iostream>
#include "../math.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "../pingus_error.hpp"
#include "dot.hpp"
#include "dot_factory.hpp"
Modified: trunk/pingus/src/worldmap/pingus_worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/pingus_worldmap.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/worldmap/pingus_worldmap.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -16,7 +16,7 @@
#include <string>
#include "../pingus_error.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "drawable_factory.hpp"
#include "pingus_worldmap.hpp"
Modified: trunk/pingus/src/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.cpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldmap/worldmap.cpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -21,14 +21,14 @@
#include "../path_manager.hpp"
#include "../stat_manager.hpp"
#include "../savegame_manager.hpp"
-#include "../system.hpp"
+#include "util/system.hpp"
#include "../resource.hpp"
#include "../globals.hpp"
#include "../sound/sound.hpp"
#include "../pingus_error.hpp"
#include "../gettext.h"
#include "../globals.hpp"
-#include "../sexpr_file_reader.hpp"
+#include "util/sexpr_file_reader.hpp"
#include "../debug.hpp"
#include "../lisp/parser.hpp"
#include "../lisp/lisp.hpp"
Modified: trunk/pingus/src/worldmap/worldmap.hpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldmap/worldmap.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -19,7 +19,7 @@
#include <vector>
#include "../sprite.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "../display/drawing_context.hpp"
#include "../graphic_context_state.hpp"
#include "pingus_worldmap.hpp"
Modified: trunk/pingus/src/worldmap/worldmap_story.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_story.cpp 2009-11-04 00:03:36 UTC
(rev 4002)
+++ trunk/pingus/src/worldmap/worldmap_story.cpp 2009-11-04 00:33:25 UTC
(rev 4003)
@@ -18,7 +18,7 @@
#include <vector>
#include "worldmap_story.hpp"
#include "../story_screen.hpp"
-#include "../file_reader.hpp"
+#include "util/file_reader.hpp"
#include "../res_descriptor.hpp"
#include "../pingus_error.hpp"
#include "../string_format.hpp"
Modified: trunk/pingus/src/worldobj.hpp
===================================================================
--- trunk/pingus/src/worldobj.hpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/worldobj.hpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -18,7 +18,7 @@
#define HEADER_PINGUS_WORLDOBJ_HPP
#include "pingus.hpp"
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
#include "sprite.hpp"
#include "collision_mask.hpp"
Modified: trunk/pingus/src/worldobj_factory.hpp
===================================================================
--- trunk/pingus/src/worldobj_factory.hpp 2009-11-04 00:03:36 UTC (rev
4002)
+++ trunk/pingus/src/worldobj_factory.hpp 2009-11-04 00:33:25 UTC (rev
4003)
@@ -19,8 +19,8 @@
#include <map>
#include <string>
-#include "file_reader.hpp"
+#include "util/file_reader.hpp"
class WorldObj;
class WorldObjAbstractFactory;
Modified: trunk/pingus/src/worldobjs/exit.cpp
===================================================================
--- trunk/pingus/src/worldobjs/exit.cpp 2009-11-04 00:03:36 UTC (rev 4002)
+++ trunk/pingus/src/worldobjs/exit.cpp 2009-11-04 00:33:25 UTC (rev 4003)
@@ -23,7 +23,7 @@
#include "../pingu.hpp"
#include "../components/smallmap.hpp"
#include "../resource.hpp"
-#include "../string_util.hpp"
+#include "util/string_util.hpp"
#include "exit.hpp"
namespace WorldObjs {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4003 - in trunk/pingus: . src src/actions src/components src/editor src/input src/util src/worldmap src/worldobjs,
grumbel at BerliOS <=