bool kax_file_c::is_level1_element_id(vint_c id) const { const EbmlSemanticContext &context = EBML_CLASS_CONTEXT(KaxSegment); for (size_t segment_idx = 0; EBML_CTX_SIZE(context) > segment_idx; ++segment_idx) if (EBML_ID_VALUE(EBML_CTX_IDX_ID(context,segment_idx)) == id.m_value) return true; return false; }
bool kax_file_c::is_level1_element_id(vint_c id) const { auto &context = EBML_CLASS_CONTEXT(KaxSegment); for (int segment_idx = 0, end = EBML_CTX_SIZE(context); end > segment_idx; ++segment_idx) if (EBML_ID_VALUE(EBML_CTX_IDX_ID(context,segment_idx)) == id.m_value) return true; return false; }
/*! \note Hopefully no global element is mandatory \todo should be called for ALL EbmlMaster element on construction */ bool EbmlMaster::ProcessMandatory() { if (EBML_CTX_SIZE(Context) == 0) { return true; } assert(Context.GetSize() != 0); unsigned int EltIdx; for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) { if (EBML_CTX_IDX(Context,EltIdx).IsMandatory() && EBML_CTX_IDX(Context,EltIdx).IsUnique()) { // assert(EBML_CTX_IDX(Context,EltIdx).Create != NULL); PushElement(EBML_SEM_CREATE(EBML_CTX_IDX(Context,EltIdx))); } } return true; }
std::vector<std::string> EbmlMaster::FindAllMissingElements() { assert(Context.GetSize() != 0); std::vector<std::string> missingElements; for (size_t ChildElementNo = 0; ChildElementNo < ElementList.size(); ChildElementNo++) { EbmlElement *childElement = ElementList[ChildElementNo]; if (!childElement->ValueIsSet()) { std::string missingValue; missingValue = "The Child Element \""; missingValue.append(EBML_NAME(childElement)); missingValue.append("\" of EbmlMaster \""); missingValue.append(EBML_NAME(this)); missingValue.append("\", does not have a value set."); missingElements.push_back(missingValue); } if (childElement->IsMaster()) { EbmlMaster *childMaster = (EbmlMaster *)childElement; std::vector<std::string> childMissingElements = childMaster->FindAllMissingElements(); for (size_t s = 0; s < childMissingElements.size(); s++) missingElements.push_back(childMissingElements[s]); } } unsigned int EltIdx; for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) { if (EBML_CTX_IDX(Context,EltIdx).IsMandatory()) { if (FindElt(EBML_CTX_IDX_INFO(Context,EltIdx)) == NULL) { std::string missingElement; missingElement = "Missing element \""; missingElement.append(EBML_INFO_NAME(EBML_CTX_IDX_INFO(Context,EltIdx))); missingElement.append("\" in EbmlMaster \""); missingElement.append(EBML_INFO_NAME(*EBML_CTX_MASTER(Context))); missingElement.append("\""); missingElements.push_back(missingElement); } } } return missingElements; }
bool EbmlMaster::CheckMandatory() const { assert(Context.GetSize() != 0); unsigned int EltIdx; for (EltIdx = 0; EltIdx < EBML_CTX_SIZE(Context); EltIdx++) { if (EBML_CTX_IDX(Context,EltIdx).IsMandatory()) { if (FindElt(EBML_CTX_IDX_INFO(Context,EltIdx)) == NULL) { #if defined(LIBEBML_DEBUG) // you are missing this Mandatory element // const char * MissingName = EBML_INFO_NAME(EBML_CTX_IDX_INFO(Context,EltIdx)); #endif // LIBEBML_DEBUG return false; } } } return true; }