• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1925 (tree)
日時2012-01-09 13:03:10
作者kbinani

ログメッセージ

[vConnect/trunk/stand2.0] added: InputStream; modified: TextInputStream, InputStreamを継承するよう修正

変更サマリ

差分

--- vConnect/trunk/stand2.0/stand/vConnectConverter.h (revision 1924)
+++ vConnect/trunk/stand2.0/stand/vConnectConverter.h (revision 1925)
@@ -37,7 +37,7 @@
3737
3838 TextInputStream reader( otoIni, "Shift_JIS" );
3939 TextOutputStream writer( (dstDir_s + "oto.ini").c_str(), "Shift_JIS", "\x0D\x0A" );
40- while( false == reader.isEOF() ){
40+ while( reader.ready() ){
4141 string buffer = reader.readLine();
4242 if( buffer.length() == 0 ){
4343 continue;
--- vConnect/trunk/stand2.0/stand/tests/TextInputStreamTest.h (revision 1924)
+++ vConnect/trunk/stand2.0/stand/tests/TextInputStreamTest.h (revision 1925)
@@ -12,7 +12,7 @@
1212 {
1313 TextInputStream reader( "fixture/TextInputStream/shift_jis_crlf.txt", "Shift_JIS" );
1414
15- CPPUNIT_ASSERT( false == reader.isEOF() );
15+ CPPUNIT_ASSERT( true == reader.ready() );
1616
1717 string actual;
1818 string expected;
@@ -20,35 +20,38 @@
2020 expected = "だ・い・じ・け・ん";
2121 CPPUNIT_ASSERT_EQUAL( expected, actual );
2222
23- CPPUNIT_ASSERT( false == reader.isEOF() );
23+ CPPUNIT_ASSERT( true == reader.ready() );
2424
2525 actual = reader.readLine();
2626 expected = "社会復帰できなくなっちゃうよ";
2727 CPPUNIT_ASSERT_EQUAL( expected, actual );
2828
29- CPPUNIT_ASSERT( true == reader.isEOF() );
29+ CPPUNIT_ASSERT( false == reader.ready() );
3030 }
3131
3232 void testTextInputStreamUTF8()
3333 {
34- TextInputStream reader( "fixture/TextInputStream/utf8_lf.txt", "UTF-8" );
34+ TextInputStream *textInputStream = new TextInputStream( "fixture/TextInputStream/utf8_lf.txt", "UTF-8" );
35+ InputStream *reader = (InputStream *)textInputStream;
3536
36- CPPUNIT_ASSERT( false == reader.isEOF() );
37+ CPPUNIT_ASSERT( true == reader->ready() );
3738
3839 string actual;
3940 string expected;
4041
41- CPPUNIT_ASSERT( false == reader.isEOF() );
42- actual = reader.readLine();
42+ CPPUNIT_ASSERT( true == reader->ready() );
43+ actual = reader->readLine();
4344 expected = "吾輩は猫である。名前はまだ無い。";
4445 CPPUNIT_ASSERT_EQUAL( expected, actual );
4546
46- CPPUNIT_ASSERT( false == reader.isEOF() );
47- actual = reader.readLine();
47+ CPPUNIT_ASSERT( true == reader->ready() );
48+ actual = reader->readLine();
4849 expected = "どこで生れたかとんと見当がつかぬ。";
4950 CPPUNIT_ASSERT_EQUAL( expected, actual );
5051
51- CPPUNIT_ASSERT( true == reader.isEOF() );
52+ CPPUNIT_ASSERT( false == reader->ready() );
53+
54+ delete textInputStream;
5255 }
5356
5457 CPPUNIT_TEST_SUITE( TextInputStreamTest );
--- vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1924)
+++ vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1925)
@@ -1,3 +1,3 @@
11 all: *.cpp *.h
2- g++ -finput-charset=UTF-8 AllTests.cpp ../../libiconv-1.13/lib/*.o -lcppunit -o run
2+ g++ -finput-charset=UTF-8 AllTests.cpp ../../libiconv-1.13/lib/*.o -lcppunit -o run
33 ./run
--- vConnect/trunk/stand2.0/stand/EncodingConverter.h (revision 1924)
+++ vConnect/trunk/stand2.0/stand/EncodingConverter.h (revision 1925)
@@ -1,3 +1,16 @@
1+/*
2+ * EncodingConverter.h
3+ * Copyright © 2012 kbinani
4+ *
5+ * This file is part of vConnect-STAND.
6+ *
7+ * vConnect-STAND is free software; you can redistribute it and/or
8+ * modify it under the terms of the GPL License.
9+ *
10+ * vConnect-STAND is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+ */
114 #ifndef __EncodingConverter_h__
215 #define __EncodingConverter_h__
316
--- vConnect/trunk/stand2.0/stand/TextInputStream.h (revision 1924)
+++ vConnect/trunk/stand2.0/stand/TextInputStream.h (revision 1925)
@@ -16,6 +16,7 @@
1616
1717 #include <stdio.h>
1818 #include "EncodingConverter.h"
19+#include "InputStream.h"
1920
2021 namespace vconnect
2122 {
@@ -23,7 +24,7 @@
2324 * テキストファイルを読み込むためのクラス
2425 * @todo 1 行が BUFFER_SIZE を超えるテキストを読む場合動作がデタラメ
2526 */
26- class TextInputStream
27+ class TextInputStream : public InputStream
2728 {
2829 private:
2930 /**
@@ -159,12 +160,12 @@
159160 }
160161
161162 /**
162- * ファイル読み込みがファイル末尾に達したかどうか
163- * @return ファイル末尾に達している場合 true を、そうでなければ false を返す。
163+ * ストリームに対してさらに読み込めるかどうか
164+ * @return 読み込める状態であれば true を返す
164165 */
165- bool isEOF()
166+ bool ready()
166167 {
167- return feof( this->fileHandle ) ? true : false;
168+ return feof( this->fileHandle ) ? false : true;
168169 }
169170
170171 /**
旧リポジトリブラウザで表示