Open-Transactions  0.93.0-ge03d287
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
opentxs::OTClause Class Reference

#include <OTClause.hpp>

Public Member Functions

void SetBylaw (OTBylaw &theBylaw)
 
EXPORT const OTStringGetName () const
 
OTBylawGetBylaw () const
 
EXPORT const char * GetCode () const
 
bool Compare (const OTClause &rhs) const
 
 OTClause ()
 
 OTClause (const char *szName, const char *szCode)
 
virtual ~OTClause ()
 
void Serialize (OTString &strAppend) const
 

Detailed Description

Definition at line 143 of file OTClause.hpp.

Constructor & Destructor Documentation

opentxs::OTClause::OTClause ( )

Definition at line 154 of file OTClause.cpp.

155  : m_pBylaw(nullptr)
156 {
157 }
opentxs::OTClause::OTClause ( const char *  szName,
const char *  szCode 
)

Definition at line 159 of file OTClause.cpp.

160  : m_pBylaw(nullptr)
161 {
162  if (nullptr != szName) m_strName.Set(szName);
163 
164  if (nullptr != szCode) m_strCode = szCode;
165 
166  // Todo security: validation on the above fields.
167 }
EXPORT void Set(const char *data, uint32_t enforcedMaxLength=0)
Definition: OTString.cpp:1055
opentxs::OTClause::~OTClause ( )
virtual

Definition at line 169 of file OTClause.cpp.

170 {
171  // nothing to delete.
172 
173  m_pBylaw =
174  nullptr; // I wasn't the owner, it was a pointer for convenience only.
175 }

Member Function Documentation

bool opentxs::OTClause::Compare ( const OTClause rhs) const

Definition at line 201 of file OTClause.cpp.

202 {
203  if (!(GetName().Compare(rhs.GetName()))) {
204  otOut << "OTClause::Compare: Names don't match: " << GetName() << " / "
205  << rhs.GetName() << " \n";
206  return false;
207  }
208 
209  if (!(m_strCode.Compare(rhs.GetCode()))) {
210  otOut << "OTClause::Compare: Source code for interpreted script fails "
211  "to match, on clause: " << GetName() << " \n";
212  return false;
213  }
214 
215  return true;
216 }
OTLOG_IMPORT OTLogStream otOut
EXPORT const OTString & GetName() const
Definition: OTClause.hpp:155
EXPORT bool Compare(const char *compare) const
Definition: OTString.cpp:1102
bool Compare(const OTClause &rhs) const
Definition: OTClause.cpp:201
OTBylaw* opentxs::OTClause::GetBylaw ( ) const
inline

Definition at line 160 of file OTClause.hpp.

161  {
162  return m_pBylaw;
163  }
const char * opentxs::OTClause::GetCode ( ) const

Definition at line 177 of file OTClause.cpp.

178 {
179  if (m_strCode.Exists()) return m_strCode.Get();
180 
181  return "print(\"(Empty script.)\")"; // todo hardcoding
182 }
EXPORT bool Exists() const
Definition: OTString.cpp:1035
EXPORT const char * Get() const
Definition: OTString.cpp:1045
EXPORT const OTString& opentxs::OTClause::GetName ( ) const
inline

Definition at line 155 of file OTClause.hpp.

156  {
157  return m_strName;
158  }
void opentxs::OTClause::Serialize ( OTString strAppend) const

Definition at line 184 of file OTClause.cpp.

185 {
186  if (m_strCode.GetLength() > 2) {
187  OTASCIIArmor ascCode;
188  ascCode.SetString(m_strCode);
189 
190  strAppend.Concatenate("<clause\n name=\"%s\">\n%s</clause>\n\n",
191  m_strName.Get(), ascCode.Get());
192  }
193  else {
194  strAppend.Concatenate("<clause\n name=\"%s\">\n%s</clause>\n\n",
195  m_strName.Get(), "ERROR_CLAUSE_CODE_nullptr");
196  otErr << "Empty script code in OTClause::Serialize()\n";
197  }
198 }
EXPORT uint32_t GetLength() const
Definition: OTString.cpp:1040
EXPORT const char * Get() const
Definition: OTString.cpp:1045
OTLOG_IMPORT OTLogStream otErr
void opentxs::OTClause::SetBylaw ( OTBylaw theBylaw)
inline

Definition at line 150 of file OTClause.hpp.

151  {
152  m_pBylaw = &theBylaw;
153  }

The documentation for this class was generated from the following files: