From f94a24a1112c9a3d013d5999e5dfaaace76fdf7a Mon Sep 17 00:00:00 2001 From: cdfrey Date: Fri, 27 Jul 2007 03:49:39 +0000 Subject: [PATCH] - added ReadDataArray() to data.h, using an istream instead of requiring a file --- src/data.cc | 11 ++++++++--- src/data.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/data.cc b/src/data.cc index e0420bb2..29f319c5 100644 --- a/src/data.cc +++ b/src/data.cc @@ -395,15 +395,20 @@ static bool IsEndpointStart(const std::string &line, int &endpoint) bool LoadDataArray(const string &filename, std::vector &array) { ifstream in(filename.c_str()); - if( !in ) + return ReadDataArray(in, array); +} + +bool ReadDataArray(std::istream &is, std::vector &array) +{ + if( !is ) return false; bool bInEndpoint = false; unsigned int nCurrent = 0; size_t nLargestSize = 0x100; - while( in ) { + while( is ) { string line; - getline(in, line); + getline(is, line); int endpoint; if( bInEndpoint ) { if( IsHexData(line) ) { diff --git a/src/data.h b/src/data.h index ae7e4cdf..5f867adf 100644 --- a/src/data.h +++ b/src/data.h @@ -98,6 +98,7 @@ std::ostream& operator<< (std::ostream &os, const Diff &diff); // utility functions bool LoadDataArray(const std::string &filename, std::vector &array); +bool ReadDataArray(std::istream &is, std::vector &array); } // namespace Barry -- 2.11.4.GIT