Commit 86ef9e86 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: make treatment of stream allocators more uniform (issue #532)

- use allocator class to wrap the stream pointers instead of passing
  them into ISstream, OSstream and using a dynamic cast to delete
  then. This is especially important if we will have a bidirectional
  stream (can't delete twice!).

STYLE:

- file stream constructors with std::string (C++11)

- for rewind, explicit about in|out direction. This is not currently
  important, but avoids surprises with any future bidirectional access.

- combined string streams in StringStream.H header.
  Similar to <sstream> include that has both input and output string
  streams.
parent b0db30ba
......@@ -31,8 +31,7 @@ Description
#include "CompactListList.H"
#include "IOstreams.H"
#include "OStringStream.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "faceList.H"
using namespace Foam;
......
......@@ -29,8 +29,7 @@ License
#include "DynamicList.H"
#include "FlatOutput.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "StringStream.H"
using namespace Foam;
......
......@@ -25,7 +25,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IStringStream.H"
#include "StringStream.H"
#include "wordList.H"
#include "IOstreams.H"
......
......@@ -37,7 +37,7 @@ See also
#include "wordReList.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "scalar.H"
#include "vector.H"
......
......@@ -25,8 +25,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "OStringStream.H"
#include "IOstreams.H"
#include "StringStream.H"
using namespace Foam;
......@@ -35,15 +35,26 @@ using namespace Foam;
int main(int argc, char *argv[])
{
Info<< "khkj" << endl;
OStringStream testStream;
testStream << "hello " << 1 << endl;
Info<< testStream.str() << endl;
testStream.rewind();
Info<< testStream.str() << endl;
testStream << "hello " << 2 << endl;
Info<< testStream.str() << endl;
Info<< "Begin test OStringStream" << endl;
OStringStream os;
os << "output with some values " << 1 << " entry" << endl;
Info<< "contains:" << nl
<< os.str() << endl;
os.rewind();
Info<< "after rewind:" << nl
<< os.str() << endl;
os << "####";
Info<< "overwrite with short string:" << nl
<< os.str() << endl;
// os.reset();
// Info<< "after reset:" << nl
// << os.str() << endl;
Info<< "End\n" << endl;
......
......@@ -30,7 +30,7 @@ Description
#include "uLabel.H"
#include "IOstreams.H"
#include "PackedBoolList.H"
#include "IStringStream.H"
#include "StringStream.H"
using namespace Foam;
......
......@@ -29,7 +29,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "IStringStream.H"
#include "StringStream.H"
#include "Polynomial.H"
#include "polynomialFunction.H"
#include "Random.H"
......
......@@ -25,8 +25,7 @@ License
#include "StaticHashTable.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "StringStream.H"
using namespace Foam;
......
......@@ -26,7 +26,6 @@ License
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "IStringStream.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
#include "OFstream.H"
......
......@@ -26,7 +26,6 @@ License
#include "argList.H"
#include "Time.H"
#include "fvMesh.H"
#include "IStringStream.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "OFstream.H"
......
......@@ -34,8 +34,6 @@ Description
#include "Time.H"
#include "polyMesh.H"
#include "IOstreams.H"
#include "OStringStream.H"
#include "IStringStream.H"
using namespace Foam;
......
......@@ -31,7 +31,6 @@ Description
#include "OSspecific.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "scalar.H"
#include "vector.H"
#include "ListOps.H"
......@@ -49,31 +48,26 @@ int main(int argc, char *argv[])
//Pout.prefix() = '[' + name(Pstream::myProcNo()) + "] ";
List<vector> list(IStringStream("1 ((0 1 2))")());
List<vector> list{{0, 1, 2}};
Info<< list << endl;
List<vector> list2
(
IStringStream
(
"(\
(0 1 2)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
(3 4 5)\
)"
)()
);
{
{0, 1, 2},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
{3, 4, 5},
};
Pout<< list2 << endl;
Info<< findIndex(list2, vector(3, 4, 5)) << endl;
......
......@@ -28,10 +28,8 @@ Description
#include "argList.H"
#include "label.H"
#include "labelList.H"
#include "OStringStream.H"
#include "IStringStream.H"
#include "OFstream.H"
#include "IFstream.H"
#include "OFstream.H"
#include "point.H"
#include "Time.H"
#include "fvMesh.H"
......
......@@ -30,7 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "OSHA1stream.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "dictionary.H"
using namespace Foam;
......
......@@ -32,7 +32,6 @@ Description
#include "dictionary.H"
#include "nil.H"
#include "IOstreams.H"
#include "IStringStream.H"
namespace Foam
{
......
......@@ -26,8 +26,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "stringListOps.H"
#include "IStringStream.H"
#include "IOstreams.H"
#include "StringStream.H"
using namespace Foam;
......@@ -37,22 +37,17 @@ using namespace Foam;
int main(int argc, char *argv[])
{
stringList strLst
(
IStringStream
(
"("
"\"hello\""
"\"heello\""
"\"heeello\""
"\"bye\""
"\"bbye\""
"\"bbbye\""
"\"okey\""
"\"okkey\""
"\"okkkey\""
")"
)()
);
{
"hello",
"heello",
"heeello",
"bye",
"bbye",
"bbbye",
"okey",
"okkey",
"okkkey",
};
wordReList reLst(IStringStream("( okey \"[hy]e+.*\" )")());
......
......@@ -31,7 +31,7 @@ Description
#include "IOobject.H"
#include "IOstreams.H"
#include "IFstream.H"
#include "IStringStream.H"
#include "StringStream.H"
#include "cpuTime.H"
using namespace Foam;
......
......@@ -30,7 +30,6 @@ Description
#include "OSspecific.H"
#include "IOstreams.H"
#include "IStringStream.H"
#include "labelList.H"
#include "DynamicList.H"
#include "face.H"
......
......@@ -46,7 +46,7 @@ Description
#include <cstdio>
#include "scalar.H"
#include "IStringStream.H"
#include "StringStream.H"
using namespace Foam;
......@@ -271,7 +271,6 @@ elementType ^{space}"TYPE"{cspace}
#include "fileName.H"
#include <fstream>
using std::ifstream;
label findFace(const polyMesh& mesh, const face& f)
......@@ -318,8 +317,8 @@ int main(int argc, char *argv[])
#include "createTime.H"
fileName ansysFile(args[1]);
ifstream ansysStream(ansysFile.c_str());
const fileName ansysFile(args[1]);
std::ifstream ansysStream(ansysFile);
if (!ansysStream)
{
......
......@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
std::ifstream plot3dFile(args[1].c_str());
std::ifstream plot3dFile(args[1]);
string line;
std::getline(plot3dFile, line);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment