Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
/**********************************************************************
text.h - Declaration and Implementation of OBText
Copyright (C) 2008 by Chris Morley
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef OB_TEXT_H
#define OB_TEXT_H
#include <openbabel/babelconfig.h>
#include <openbabel/base.h>
namespace OpenBabel
{
class OBText : public OBBase
{
private:
std::string txt;
public:
//Constructors
OBText(){}
OBText(const std::string& text) :txt(text) {}
std::string GetText()const { return txt; }
std::string GetText(std::string::size_type& pos, bool ToInsertOnly=false) const
{
std::string::size_type oldpos = pos;
std::string::size_type newpos = txt.find("OPENBABEL_INSERT", pos);
if(newpos== std::string::npos)//not found: return rest of txt
{
if(ToInsertOnly)
return("");
pos = 0;
return txt.substr(oldpos);
}
newpos = txt.rfind('\n', newpos); //to end of previous line
pos = txt.find("\n", newpos+1)+1; //to past end of line, or 0
return txt.substr(oldpos, newpos-oldpos);
}
void SetText(const std::string& text){ txt = text; }
};
}//namespace
#endif //OB_TEXT_H
base.h
Base classes to build a graph.
OpenBabel::OBBase
Base Class.
Definition base.h:240
OpenBabel::OBText::GetText
std::string GetText(std::string::size_type &pos, bool ToInsertOnly=false) const
Definition text.h:68
OpenBabel::OBText::GetText
std::string GetText() const
Definition text.h:39
OpenBabel::OBText::SetText
void SetText(const std::string &text)
Definition text.h:85
OpenBabel::OBText::OBText
OBText()
Definition text.h:35
OpenBabel::OBText::OBText
OBText(const std::string &text)
Definition text.h:36
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23