From f9577a429fbf55370265a916ad885395b53221c9 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Tue, 15 May 2012 14:04:06 +0100 Subject: [PATCH] BUG: UOPstream: transferring VERBATIMSTRING --- src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C | 10 ++++++++-- src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C | 17 +++++++++++++---- src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C | 12 ++++++++++-- .../db/IOstreams/Sstreams/prefixOSstream.C | 12 ++++++++++-- .../primitiveEntry/primitiveEntryIO.C | 8 ++++---- 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 3e095272db4..2167d15b6de 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -165,8 +165,14 @@ Foam::Istream& Foam::UIPstream::read(token& t) } // String - case token::STRING : case token::VERBATIMSTRING : + { + // Recurse to read actual string + read(t); + t.type() = token::VERBATIMSTRING; + return *this; + } + case token::STRING : { string* pval = new string; if (read(*pval)) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index c257826c047..e01e8de01bd 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -151,10 +151,19 @@ Foam::UOPstream::~UOPstream() // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -Foam::Ostream& Foam::UOPstream::write(const token&) +Foam::Ostream& Foam::UOPstream::write(const token& t) { - notImplemented("Ostream& UOPstream::write(const token&)"); - setBad(); + // Raw token output only supported for verbatim strings for now + if (t.type() == token::VERBATIMSTRING) + { + write(char(token::VERBATIMSTRING)); + write(t.stringToken()); + } + else + { + notImplemented("Ostream& UOPstream::write(const token&)"); + setBad(); + } return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C index 2dbf0c11505..4cbf8bf1fa9 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,8 +29,16 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::Ostream& Foam::OSstream::write(const token&) +Foam::Ostream& Foam::OSstream::write(const token& t) { + if (t.type() == token::VERBATIMSTRING) + { + write(char(token::HASH)); + write(char(token::BEGIN_BLOCK)); + writeQuoted(t.stringToken(), false); + write(char(token::HASH)); + write(char(token::END_BLOCK)); + } return *this; } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C index b46a9b81092..7ca977bf978 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,8 +65,16 @@ void Foam::prefixOSstream::print(Ostream& os) const } -Foam::Ostream& Foam::prefixOSstream::write(const token&) +Foam::Ostream& Foam::prefixOSstream::write(const token& t) { + if (t.type() == token::VERBATIMSTRING) + { + write(char(token::HASH)); + write(char(token::BEGIN_BLOCK)); + writeQuoted(t.stringToken(), false); + write(char(token::HASH)); + write(char(token::END_BLOCK)); + } return *this; } diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 021f146536f..fd442af47ae 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -225,9 +225,9 @@ void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const const token& t = operator[](i); if (t.type() == token::VERBATIMSTRING) { - os << token::HASH << token::BEGIN_BLOCK; - os.writeQuoted(t.stringToken(), false); - os << token::HASH << token::END_BLOCK; + // Bypass token output operator to avoid losing verbatimness. + // Handle in Ostreams themselves + os.write(t); } else { -- GitLab