void SoSFBitMask::writeValue(SoOutput *out) const // //////////////////////////////////////////////////////////////////////// { const SbName *n; int i; #ifdef DEBUG if (enumValues == NULL) { SoDebugError::post("SoSFBitMask::writeValue", "Enum values were never initialized"); return; } #endif /* DEBUG */ // Look for one flag that matches entire value (if any) if (findEnumName(value, n)) out->write(n->getString()); // Otherwise, pull out 1 bit mask at a time until the value is complete else { int v = value; if (! out->isBinary()) out->write(OPEN_PAREN); for (i = 0; i < numEnums; i++) { // Mask must match exactly if ( (enumValues[i] & v) == enumValues[i]) { out->write(enumNames[i].getString()); // Turn off those bits v &= ~enumValues[i]; if (v == 0) break; if (! out->isBinary()) { out->write(' '); out->write(BITWISE_OR); out->write(' '); } } } // All bits must have been written out if (v != 0) SoDebugError::post("SoSFBitMask::writeValue", "unable to write some bits (%#x)", v); if (! out->isBinary()) out->write(CLOSE_PAREN); } if (out->isBinary()) out->write(""); }
void SoSFEnum::writeValue(SoOutput * out) const { const SbName *enumname; if (findEnumName(this->getValue(), enumname)) { out->write(const_cast<char *>(enumname->getString())); return; } // If we don't have any legal values for this field, // pass through read integer values. if (!this->legalValuesSet) { out->write(this->getValue()); return; } #if COIN_DEBUG // An unknown enumeration value will usually be an indication of a // more serious bug, so we elaborate a bit on the error to aid early // debugging. mortene. SbName name; const SoFieldContainer * thecontainer = this->getContainer(); const SbBool fname = thecontainer && thecontainer->getFieldName(this, name); SbString s(""); if (fname) { s.sprintf(" \"%s\"", name.getString()); } SoDebugError::post("SoSFEnum::writeValue", "Illegal enumeration value %d in field%s", this->getValue(), s.getString()); #endif // COIN_DEBUG }
void SoSFEnum::writeValue(SoOutput *out) const // //////////////////////////////////////////////////////////////////////// { const SbName *n; #ifdef DEBUG if (enumValues == NULL) { SoDebugError::post("SoSFEnum::writeValue", "Enum values were never initialized"); return; } #endif /* DEBUG */ // Find and write string corresponding to given value if (findEnumName(value, n)) out->write(n->getString()); // Whoops! Something bad was in the field value else { SoDebugError::post("SoSFEnum::writeValue", "Illegal value (%d) in field", value); } }