[geos-commits] r3769 - in trunk: . include/geos/io src/io tests/unit/io

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Feb 25 02:37:38 PST 2013


Author: strk
Date: 2013-02-25 02:37:36 -0800 (Mon, 25 Feb 2013)
New Revision: 3769

Modified:
   trunk/NEWS
   trunk/include/geos/io/Writer.h
   trunk/src/io/Writer.cpp
   trunk/tests/unit/io/WriterTest.cpp
Log:
New ::reserve(size_t) method for io::Writer class

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2013-02-25 10:34:10 UTC (rev 3768)
+++ trunk/NEWS	2013-02-25 10:37:36 UTC (rev 3769)
@@ -8,6 +8,7 @@
   - GeometryPrecisionReducer class
   - BufferInputLineSimplifier header exposed (#548)
   - New Centroid class supporting mixed geometry components (#612)
+  - io::Writer::reserve() method
 - C++ API changes:
   - New noding::GeometryNoder class
   - Added BufferOp::setSingleSided 

Modified: trunk/include/geos/io/Writer.h
===================================================================
--- trunk/include/geos/io/Writer.h	2013-02-25 10:34:10 UTC (rev 3768)
+++ trunk/include/geos/io/Writer.h	2013-02-25 10:37:36 UTC (rev 3769)
@@ -35,6 +35,7 @@
 class GEOS_DLL Writer {
 public:
 	Writer();
+	void reserve(std::size_t capacity);
 	~Writer();
 	void write(const std::string& txt);
 	const std::string& toString();

Modified: trunk/src/io/Writer.cpp
===================================================================
--- trunk/src/io/Writer.cpp	2013-02-25 10:34:10 UTC (rev 3768)
+++ trunk/src/io/Writer.cpp	2013-02-25 10:37:36 UTC (rev 3769)
@@ -29,6 +29,12 @@
 {
 }
 
+void
+Writer::reserve(std::size_t capacity)
+{
+  str.reserve(capacity);
+}
+
 Writer::~Writer()
 {
 }

Modified: trunk/tests/unit/io/WriterTest.cpp
===================================================================
--- trunk/tests/unit/io/WriterTest.cpp	2013-02-25 10:34:10 UTC (rev 3768)
+++ trunk/tests/unit/io/WriterTest.cpp	2013-02-25 10:37:36 UTC (rev 3769)
@@ -45,6 +45,42 @@
     ensure_equals(writer.toString(), "Hello World!");
   }
 
+	template<>
+	template<>
+	void object::test<2>()
+	{         
+    geos::io::Writer writer;
+
+    writer.reserve(512);
+    writer.write("Hello ");
+    writer.write("World!");
+    ensure_equals(writer.toString(), "Hello World!");
+  }
+
+	template<>
+	template<>
+	void object::test<3>()
+	{         
+    geos::io::Writer writer;
+
+    writer.reserve(1);
+    writer.write("Hello ");
+    writer.write("World!");
+    ensure_equals(writer.toString(), "Hello World!");
+  }
+
+	template<>
+	template<>
+	void object::test<4>()
+	{         
+    geos::io::Writer writer;
+
+    writer.reserve(512);
+    writer.write("Hello World!");
+    writer.reserve(1);
+    ensure_equals(writer.toString(), "Hello World!");
+  }
+
 } // namespace tut
 
 



More information about the geos-commits mailing list