void nImO::Array::printToStringBuffer (nImO::StringBuffer & outBuffer, const bool squished) const { ODL_OBJENTER(); //#### ODL_P1("outBuffer = ", &outBuffer); //#### ODL_B1("squished = ", squished); //#### bool first = true; outBuffer.addChar(kStartArrayChar); for (const_iterator walker(inherited2::begin()); inherited2::end() != walker; ++walker) { SpValue aValue(*walker); if (nullptr != aValue) { if ((! squished) || (! first)) { outBuffer.addChar(' '); } aValue->printToStringBuffer(outBuffer, squished); first = false; } } if (! squished) { outBuffer.addChar(' '); } outBuffer.addChar(kEndArrayChar); ODL_OBJEXIT(); //#### } // nImO::Array::printToStringBuffer
nImO::Array::Array (const nImO::Array & other) : inherited1(), inherited2() { ODL_ENTER(); //#### ODL_P1("other = ", &other); //#### addEntries(other); ODL_EXIT_P(this); //#### } // nImO::Array::Array
nImO::Array & nImO::Array::addEntries (const nImO::Array & other) { ODL_ENTER(); //#### ODL_P1("other = ", &other); //#### for (auto & walker : other) { addValue(walker); } ODL_EXIT_P(this); //#### return *this; } // nImO::Array::addEntries
ServiceEntity::ServiceEntity(const PortPanel::EntityKind kind, const string & behaviour, const string & description, ServiceViewerApp & owner) : inherited(), _panel(kind, behaviour, description, owner, *this), _node(NULL), _drawConnectMarker(false), _drawDisconnectMarker(false), _drawMoveMarker(false), _selected(false) { ODL_ENTER(); //#### ODL_S2s("behaviour = ", behaviour, "description = ", description); //#### ODL_P1("owner = ", &owner); //#### ODL_EXIT_P(this); //#### } // ServiceEntity::ServiceEntity
bool nImO::Array::deeplyEqualTo (const nImO::Value & other) const { ODL_OBJENTER(); //#### ODL_P1("other = ", &other); //#### bool result = (&other == this); if (! result) { const Array * otherPtr = other.asArray(); if (otherPtr && (size() == otherPtr->size())) { const_iterator thisWalker(inherited2::begin()); const_iterator otherWalker(otherPtr->inherited2::begin()); for (result = true; result && (thisWalker != inherited2::end()); ++thisWalker, ++otherWalker) { SpValue thisValue(*thisWalker); SpValue otherValue(*otherWalker); if ((nullptr != thisValue) && (nullptr != otherValue)) { result = thisValue->deeplyEqualTo(*otherValue); } else { result = false; } } } } ODL_OBJEXIT_B(result); //#### return result; } // nImO::Array::deeplyEqualTo
void nImO::Array::writeToMessage (nImO::Message & outMessage) const { ODL_ENTER(); //#### ODL_P1("outMessage = ", &outMessage); //#### if (0 < inherited2::size()) { ODL_LOG("(0 < inherited2::size())"); //#### DataKind startArray = (DataKind::Other | DataKind::OtherContainerStart | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); DataKind endArray = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); std::queue<double> doublesSeen; outMessage.appendBytes(&startArray, sizeof(startArray)); writeInt64ToMessage(outMessage, static_cast<int>(inherited2::size()) + DataKindIntegerShortValueMinValue - 1); for (const_iterator walker(inherited2::begin()); inherited2::end() != walker; ++walker) { SpValue aValue(*walker); if (aValue) { // Check for sequences of Double values const Double * doubleValue = aValue->asDouble(); if (nullptr == doubleValue) { Double::writeValuesToMessage(doublesSeen, outMessage); aValue->writeToMessage(outMessage); } else { doublesSeen.push(doubleValue->getDoubleValue()); } } } // Write out any held Double values Double::writeValuesToMessage(doublesSeen, outMessage); outMessage.appendBytes(&endArray, sizeof(endArray)); } else { ODL_LOG("! (0 < inherited2::size())"); //#### static const DataKind stuff[] = { (DataKind::Other | DataKind::OtherContainerStart | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue), (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue) }; outMessage.appendBytes(stuff, sizeof(stuff)); } ODL_EXIT(); //#### } // nImO::Array::writeToMessage
nImO::SpValue nImO::Array::readFromStringBuffer (const nImO::StringBuffer & inBuffer, size_t & position) { ODL_ENTER(); //#### ODL_P2("inBuffer = ", &inBuffer, "position = ", &position); //#### bool atEnd; bool done = false; bool valid = false; auto result = std::make_shared<Array>(); size_t localIndex = position; int aChar = inBuffer.getChar(localIndex++, atEnd); ODL_P1("result <- ", result.get()); //#### ODL_I1("localIndex <- ", localIndex); //#### ODL_C1("aChar <- ", aChar); //#### ODL_B1("atEnd <- ", atEnd); //#### if ((! atEnd) && (kStartArrayChar == aChar)) { for ( ; ! done; ) { // Skip whitespace for (aChar = inBuffer.getChar(localIndex, atEnd); (! atEnd) && isspace(aChar); aChar = inBuffer.getChar(++localIndex, atEnd)) { ODL_I1("localIndex <- ", localIndex); //#### ODL_C1("aChar <- ", aChar); //#### ODL_B1("atEnd <- ", atEnd); //#### } ODL_I1("localIndex = ", localIndex); //#### ODL_C1("aChar = ", aChar); //#### // Check for the closing bracket if (atEnd) { ODL_LOG("(atEnd)"); //#### done = true; } else if (kEndArrayChar == aChar) { done = valid = true; } else { SpValue element(Value::readFromStringBuffer(inBuffer, localIndex)); ODL_I1("localIndex <- ", localIndex); //#### if (nullptr == element) { ODL_LOG("(nullptr == element)"); //#### done = true; } else { result->addValue(element); } } } } else { ODL_LOG("! (kStartArrayChar == aChar)"); //#### } if (valid) { position = localIndex + 1; } else { ODL_LOG("! (valid)"); //#### result.reset(); } ODL_EXIT_P(result.get()); //#### return result; } // nImO::Array::readFromStringBuffer