Commit 23dd3e07 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: provide for writing contents only from dictionary entries

parent f4a84af4
......@@ -477,7 +477,8 @@ public:
// Write
void write(Ostream&, bool subDict=true) const;
//- Write dictionary, normally with sub-dictionary formatting
void write(Ostream&, const bool subDict=true) const;
// Member Operators
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -146,7 +146,7 @@ public:
//- Return non-const access to dictionary
dictionary& dict();
// Write
//- Write
void write(Ostream&) const;
//- Return info proxy.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -168,6 +168,9 @@ public:
//- Write
void write(Ostream&) const;
//- Write, optionally with contents only (no keyword, etc)
void write(Ostream&, const bool contentsOnly) const;
//- Return info proxy.
// Used to print token information to a stream
InfoProxy<primitiveEntry> info() const
......
......@@ -210,31 +210,43 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::primitiveEntry::write(Ostream& os) const
void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
{
os.writeKeyword(keyword());
if (!contentsOnly)
{
os.writeKeyword(keyword());
}
for (label i=0; i<size(); ++i)
{
const token& t = operator[](i);
if (t.type() == token::VERBATIMSTRING)
{
os << token::HASH << token::BEGIN_BLOCK;
os << token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(t.stringToken(), false);
os << token::HASH << token::END_BLOCK;
os << token::HASH << token::END_BLOCK;
}
else
{
os << t;
os << t;
}
if (i < size()-1)
{
os << token::SPACE;
os << token::SPACE;
}
}
os << token::END_STATEMENT << endl;
if (!contentsOnly)
{
os << token::END_STATEMENT << endl;
}
}
void Foam::primitiveEntry::write(Ostream& os) const
{
this->write(os, false);
}
......
......@@ -128,19 +128,15 @@ namespace stringOps
string& inplaceTrimLeft(string&);
//- Return string trimmed of trailing whitespace
// NOT IMPLEMENTED
string trimRight(const string&);
//- Trim trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrimRight(string&);
//- Return string trimmed of leading and trailing whitespace
// NOT IMPLEMENTED
string trim(const string&);
//- Trim leading and trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrim(string&);
......
Supports Markdown
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