10 #include "textarrayformat.h"
14 textarrayformat::TextArrayReader::TextArrayReader(std::istream& is) :
15 splitter_(), blocks_()
22 void textarrayformat::TextArrayReader::open(std::istream& is)
27 if (!std::getline(is, tmp))
29 // 最初の一行が取得できない場合、これは失敗とする。
30 throw "can't get splitter line";
37 while (getline(is, tmp)) {
46 this->blocks_.push_back(block);
51 // 最後に殘っている場合があるのでこうしておく。
54 this->blocks_.push_back(block);
58 std::string textarrayformat::TextArrayReader::get(int num)
60 // ここはassertではなく、通常の例外によるチェックを行う。
63 throw textarrayformat::OutOfIndexException("Argument must be greater than zero");
66 if (static_cast<size_t>(num) >= blocks_.size())
69 ss << "Argument must be less than blocks num : size [" << blocks_.size()
70 << "] and receive value is [" << num << "]" << endl;
72 throw textarrayformat::OutOfIndexException(ss.str());
75 // 本当はここでatにしておけば、事前のチェックは必要無いはず。
79 textarrayformat::OutOfIndexException::OutOfIndexException(const std::string& str) :
84 const char* textarrayformat::OutOfIndexException::what() const throw()