ENH: provide for writing contents only from dictionary entries

This commit is contained in:
Mark Olesen
2011-02-23 13:02:36 +01:00
parent f4a84af465
commit 23dd3e072b
6 changed files with 28 additions and 16 deletions

View File

@ -477,7 +477,8 @@ public:
// Write // 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 // Member Operators

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -146,7 +146,7 @@ public:
//- Return non-const access to dictionary //- Return non-const access to dictionary
dictionary& dict(); dictionary& dict();
// Write //- Write
void write(Ostream&) const; void write(Ostream&) const;
//- Return info proxy. //- Return info proxy.

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -168,6 +168,9 @@ public:
//- Write //- Write
void write(Ostream&) const; void write(Ostream&) const;
//- Write, optionally with contents only (no keyword, etc)
void write(Ostream&, const bool contentsOnly) const;
//- Return info proxy. //- Return info proxy.
// Used to print token information to a stream // Used to print token information to a stream
InfoProxy<primitiveEntry> info() const InfoProxy<primitiveEntry> info() const

View File

@ -210,31 +210,43 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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) for (label i=0; i<size(); ++i)
{ {
const token& t = operator[](i); const token& t = operator[](i);
if (t.type() == token::VERBATIMSTRING) if (t.type() == token::VERBATIMSTRING)
{ {
os << token::HASH << token::BEGIN_BLOCK; os << token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(t.stringToken(), false); os.writeQuoted(t.stringToken(), false);
os << token::HASH << token::END_BLOCK; os << token::HASH << token::END_BLOCK;
} }
else else
{ {
os << t; os << t;
} }
if (i < size()-1) 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);
} }

View File

@ -128,19 +128,15 @@ namespace stringOps
string& inplaceTrimLeft(string&); string& inplaceTrimLeft(string&);
//- Return string trimmed of trailing whitespace //- Return string trimmed of trailing whitespace
// NOT IMPLEMENTED
string trimRight(const string&); string trimRight(const string&);
//- Trim trailing whitespace inplace //- Trim trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrimRight(string&); string& inplaceTrimRight(string&);
//- Return string trimmed of leading and trailing whitespace //- Return string trimmed of leading and trailing whitespace
// NOT IMPLEMENTED
string trim(const string&); string trim(const string&);
//- Trim leading and trailing whitespace inplace //- Trim leading and trailing whitespace inplace
// NOT IMPLEMENTED
string& inplaceTrim(string&); string& inplaceTrim(string&);