MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / CreateMd4Block

Method CreateMd4Block

lib/mdflib/mdflib/src/mdfblock.cpp:828–855  ·  view source on GitHub ↗

void MdfBlock::UpdateBlockSize(std::FILE *file, size_t bytes) { auto pos = FilePosition(); if (pos <= 0) { throw std::runtime_error("Invalid file position"); } if (file == nullptr) { throw std::runtime_error("File pointer is null"); } if (IsMdf4()) { if (block_length_ != static_cast (bytes)) { block_length_ = static_cast (bytes); pos += 8;

Source from the content-addressed store, hash-verified

826}
827*/
828void MdfBlock::CreateMd4Block() {
829 const auto *metadata = MetaData();
830 if (md_comment_ && md_comment_->BlockType() == "MD") {
831 // Already done
832 return;
833 }
834
835 // Create an MD block and optional copy the text if it was a TX block
836 auto md4 = std::make_unique<Md4Block>();
837
838 std::ostringstream root_name;
839 root_name << BlockType() << "comment";
840
841 auto xml = CreateXmlFile();
842 xml->RootName(root_name.str());
843
844 if (md_comment_) {
845 const auto *tx4 = dynamic_cast<const Tx4Block *>(md_comment_.get());
846 xml->SetProperty("TX", tx4 != nullptr ? tx4->TxComment() : std::string());
847 }
848
849 if (this->BlockType() == "HD") {
850 xml->SetProperty("TX", std::string());
851 }
852
853 md4->XmlSnippet(xml->WriteString(true));
854 md_comment_ = std::move(md4);
855}
856
857IMetaData *MdfBlock::CreateMetaData() {
858 CreateMd4Block();

Callers

nothing calls this directly

Calls 8

BlockTypeMethod · 0.95
CreateXmlFileFunction · 0.85
RootNameMethod · 0.80
XmlSnippetMethod · 0.80
WriteStringMethod · 0.80
getMethod · 0.45
SetPropertyMethod · 0.45
TxCommentMethod · 0.45

Tested by

no test coverage detected