290 if ((m_strName.
Compare(rhs.GetName())) &&
291 (m_strLanguage.
Compare(rhs.GetLanguage()))) {
293 otOut <<
"OTBylaw::Compare: The variable count doesn't match for "
294 "bylaw: " << m_strName <<
"\n";
298 otOut <<
"OTBylaw::Compare: The clause count doesn't match for "
299 "bylaw: " << m_strName <<
"\n";
304 <<
"OTBylaw::Compare: The hook count doesn't match for bylaw: "
305 << m_strName <<
"\n";
309 otOut <<
"OTBylaw::Compare: The callback count doesn't match for "
310 "bylaw: " << m_strName <<
"\n";
316 for (
const auto& it : m_mapVariables) {
317 OTVariable* pVar = it.second;
320 OTVariable* pVar2 = rhs.GetVariable(pVar->GetName().Get());
322 if (
nullptr == pVar2) {
323 otOut <<
"OTBylaw::Compare: Failed: Variable not found: "
324 << pVar->GetName() <<
".\n";
327 if (!pVar->Compare(*pVar2)) {
328 otOut <<
"OTBylaw::Compare: Failed comparison between 2 "
329 "variables named " << pVar->GetName() <<
".\n";
334 for (
const auto& it : m_mapClauses) {
335 OTClause* pClause = it.second;
338 OTClause* pClause2 = rhs.GetClause(pClause->GetName().Get());
340 if (
nullptr == pClause2) {
341 otOut <<
"OTBylaw::Compare: Failed: Clause not found: "
342 << pClause->GetName() <<
".\n";
345 if (!pClause->Compare(*pClause2)) {
346 otOut <<
"OTBylaw::Compare: Failed comparison between 2 "
347 "clauses named " << pClause->GetName() <<
".\n";
352 for (
const auto& it : m_mapCallbacks) {
353 const std::string& str_callback_name = it.first;
354 const std::string& str_clause_name = it.second;
356 OTClause* pCallbackClause =
GetCallback(str_callback_name);
357 OTClause* pCallbackClause2 = rhs.GetCallback(str_callback_name);
359 if (
nullptr == pCallbackClause) {
360 otOut <<
"OTBylaw::Compare: Failed: Callback ("
361 << str_callback_name <<
") clause (" << str_clause_name
362 <<
") not found on this bylaw: " << m_strName <<
".\n";
365 else if (
nullptr == pCallbackClause2) {
366 otOut <<
"OTBylaw::Compare: Failed: Callback ("
367 << str_callback_name <<
") clause (" << str_clause_name
368 <<
") not found on rhs bylaw: " << rhs.GetName() <<
".\n";
371 else if (!(pCallbackClause->GetName().Compare(
372 pCallbackClause2->GetName()))) {
373 otOut <<
"OTBylaw::Compare: Failed: Callback ("
374 << str_callback_name <<
") clause (" << str_clause_name
375 <<
") on rhs has a different name ("
376 << pCallbackClause2->GetName()
377 <<
") than *this bylaw: " << m_strName <<
".\n";
389 std::set<std::string> theHookSet;
393 for (
const auto& it : m_mapHooks) {
394 const std::string& str_hook_name = it.first;
395 theHookSet.insert(str_hook_name);
399 for (
const auto& it_hook : theHookSet) {
400 const std::string& str_hook_name = it_hook;
404 if (!
GetHooks(str_hook_name, theHookClauses) ||
405 !rhs.GetHooks(str_hook_name, theHookClauses2)) {
406 otOut <<
"OTBylaw::Compare: Failed finding hook ("
408 <<
") clauses on this bylaw or rhs bylaw: " << m_strName
413 if (theHookClauses.size() != theHookClauses2.size()) {
414 otOut <<
"OTBylaw::Compare: Hook (" << str_hook_name
415 <<
") clauses count doesn't match between this bylaw and "
416 "the rhs bylaw named: " << m_strName <<
"\n";
420 for (
auto& it : theHookClauses) {
421 const std::string str_clause_name = it.first;
422 OTClause* pClause = it.second;
425 auto it_rhs = theHookClauses2.find(str_clause_name);
427 if (theHookClauses2.end() == it_rhs) {
428 otOut <<
"OTBylaw::Compare: Unable to find hook clause ("
430 <<
") on rhs that was definitely present on *this. "
431 "Bylaw: " << m_strName <<
"\n";
EXPORT int32_t GetHookCount() const
EXPORT OTClause * GetCallback(std::string str_CallbackName)
OTLOG_IMPORT OTLogStream otOut
EXPORT bool GetHooks(std::string str_HookName, mapOfClauses &theResults)
EXPORT int32_t GetClauseCount() const
std::map< std::string, OTClause * > mapOfClauses
EXPORT int32_t GetCallbackCount() const
EXPORT bool Compare(const char *compare) const
EXPORT int32_t GetVariableCount() const