00001 /* 00002 * DaqFromStrStream.cc 00003 * FileReadoutFormat 00004 * 00005 * Created by Simon Patton on 7/18/10. 00006 * Copyright 2010 DayaBay Collaboration. All rights reserved. 00007 * 00008 */ 00009 #include "FileReadoutFormat/DaqFromStrStream.h" 00010 00011 #include <sstream> 00012 #include <string> 00013 00014 using DybDaq::DaqFromIStream; 00015 using DybDaq::DaqFromStrStream; 00016 using std::istream; 00017 using std::istringstream; 00018 using std::string; 00019 00020 DaqFromStrStream::DaqFromStrStream() : 00021 m_contents(0), 00022 m_stringstream(0) { 00023 } 00024 00025 DaqFromStrStream::~DaqFromStrStream() { 00026 // deleting m_stringstream taken care by superclass. 00027 if (0 != m_contents) { 00028 delete m_contents; 00029 } 00030 } 00031 00032 std::istream* DaqFromStrStream::openStream() { 00033 m_stringstream = new istringstream(*m_contents); 00034 return m_stringstream; 00035 } 00036 00037 void DaqFromStrStream::closeStream(std::istream& /* stream */) { 00038 // deleting m_stringStream taken care by superclass. 00039 m_stringstream = 0; 00040 } 00041 00042 const bool DaqFromStrStream::openWithString(const string& contents) { 00043 if (0 != m_contents) { 00044 delete m_contents; 00045 } 00046 m_contents = new string(contents); 00047 return open(); 00048 }