[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4047 - in trunk/pingus: src/pingus src/util test
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4047 - in trunk/pingus: src/pingus src/util test |
Date: |
Fri, 6 Nov 2009 01:02:14 +0100 |
Author: grumbel
Date: 2009-11-06 01:02:11 +0100 (Fri, 06 Nov 2009)
New Revision: 4047
Added:
trunk/pingus/src/util/line_iterator.cpp
trunk/pingus/src/util/line_iterator.hpp
Removed:
trunk/pingus/src/pingus/line_iterator.cpp
trunk/pingus/src/pingus/line_iterator.hpp
Modified:
trunk/pingus/src/pingus/font.cpp
trunk/pingus/test/line_iterator_test.cpp
Log:
Moved LineIterator to util/
Modified: trunk/pingus/src/pingus/font.cpp
===================================================================
--- trunk/pingus/src/pingus/font.cpp 2009-11-05 23:43:42 UTC (rev 4046)
+++ trunk/pingus/src/pingus/font.cpp 2009-11-06 00:02:11 UTC (rev 4047)
@@ -22,7 +22,7 @@
#include "SDL.h"
#include "SDL_image.h"
#include "engine/display/surface.hpp"
-#include "pingus/line_iterator.hpp"
+#include "util/line_iterator.hpp"
#include "util/utf8.hpp"
#include "pingus/font_description.hpp"
#include "engine/display/framebuffer.hpp"
Deleted: trunk/pingus/src/pingus/line_iterator.cpp
===================================================================
--- trunk/pingus/src/pingus/line_iterator.cpp 2009-11-05 23:43:42 UTC (rev
4046)
+++ trunk/pingus/src/pingus/line_iterator.cpp 2009-11-06 00:02:11 UTC (rev
4047)
@@ -1,60 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 "pingus/line_iterator.hpp"
-
-LineIterator::LineIterator(const std::string& str)
- : first(str.begin()),
- last(str.end()),
- line_end(str.begin())
-{
-}
-
-LineIterator::LineIterator(std::string::const_iterator first_,
- std::string::const_iterator last_)
- : first(first_),
- last(last_),
- line_end(first_)
-{
-}
-
-bool
-LineIterator::next()
-{
- if (line_end == last || (line_end+1 == last && *first == '\n'))
- {
- return false;
- }
- else
- {
- if (first != line_end)
- first = line_end + 1;
-
- do {
- ++line_end;
- } while(line_end != last && *line_end != '\n');
-
- return true;
- }
-}
-
-std::string
-LineIterator::get()
-{
- return std::string(first, line_end);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/line_iterator.hpp
===================================================================
--- trunk/pingus/src/pingus/line_iterator.hpp 2009-11-05 23:43:42 UTC (rev
4046)
+++ trunk/pingus/src/pingus/line_iterator.hpp 2009-11-06 00:02:11 UTC (rev
4047)
@@ -1,52 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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_PINGUS_LINE_ITERATOR_HPP
-#define HEADER_PINGUS_PINGUS_LINE_ITERATOR_HPP
-
-#include <string>
-
-/** Splits a given string at newlines, a new line at the end of the
- * string is ignored, others are returned as empty lines. Newlines
- * aren't included in the returned string.Use via:
- *
- * LineIterator it("Hello\nWorld);
- * while(it.next())
- * std::cout << it.get() << std::endl;
- */
-class LineIterator
-{
-private:
- std::string::const_iterator first;
- std::string::const_iterator last;
- std::string::const_iterator line_end;
-
-public:
- LineIterator(const std::string& str);
- LineIterator(std::string::const_iterator first,
- std::string::const_iterator last);
-
- /** @return false when no characters are left in the string, true
- otherwise */
- bool next();
-
- /** @return the current line */
- std::string get();
-};
-
-#endif
-
-/* EOF */
Copied: trunk/pingus/src/util/line_iterator.cpp (from rev 4046,
trunk/pingus/src/pingus/line_iterator.cpp)
===================================================================
--- trunk/pingus/src/pingus/line_iterator.cpp 2009-11-05 23:43:42 UTC (rev
4046)
+++ trunk/pingus/src/util/line_iterator.cpp 2009-11-06 00:02:11 UTC (rev
4047)
@@ -0,0 +1,60 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2007 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 "util/line_iterator.hpp"
+
+LineIterator::LineIterator(const std::string& str)
+ : first(str.begin()),
+ last(str.end()),
+ line_end(str.begin())
+{
+}
+
+LineIterator::LineIterator(std::string::const_iterator first_,
+ std::string::const_iterator last_)
+ : first(first_),
+ last(last_),
+ line_end(first_)
+{
+}
+
+bool
+LineIterator::next()
+{
+ if (line_end == last || (line_end+1 == last && *first == '\n'))
+ {
+ return false;
+ }
+ else
+ {
+ if (first != line_end)
+ first = line_end + 1;
+
+ do {
+ ++line_end;
+ } while(line_end != last && *line_end != '\n');
+
+ return true;
+ }
+}
+
+std::string
+LineIterator::get()
+{
+ return std::string(first, line_end);
+}
+
+/* EOF */
Copied: trunk/pingus/src/util/line_iterator.hpp (from rev 4037,
trunk/pingus/src/pingus/line_iterator.hpp)
Modified: trunk/pingus/test/line_iterator_test.cpp
===================================================================
--- trunk/pingus/test/line_iterator_test.cpp 2009-11-05 23:43:42 UTC (rev
4046)
+++ trunk/pingus/test/line_iterator_test.cpp 2009-11-06 00:02:11 UTC (rev
4047)
@@ -16,7 +16,7 @@
#include <iostream>
-#include "pingus/line_iterator.hpp"
+#include "util/line_iterator.hpp"
void test(const std::string& str)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4047 - in trunk/pingus: src/pingus src/util test,
grumbel at BerliOS <=