MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / getSafeWstringValue

Method getSafeWstringValue

src/BookmarkMgr.cpp:583–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string& childNodeName) {
584
585 std::wstring decodedWString;
586
587 if (node != nullptr) {
588
589 DataNode* childNode = node->getNext(childNodeName.c_str());
590
591 //1) decode as encoded wstring:
592 try {
593 childNode->element()->get(decodedWString);
594
595 } catch (const DataTypeMismatchException &) {
596 //2) wstring decode fail, try simple std::string
597 std::string decodedStdString;
598 try {
599
600 childNode->element()->get(decodedStdString);
601
602 //use wxString for a clean conversion to a wstring:
603 decodedWString = wxString(decodedStdString).ToStdWstring();
604
605 } catch (const DataTypeMismatchException &) {
606 //nothing works, return an empty string.
607 decodedWString = L"";
608 }
609 }
610 }
611
612 return decodedWString;
613}
614
615BookmarkEntryPtr BookmarkMgr::nodeToBookmark(DataNode *node) {
616 if (!node->hasAnother("frequency") || !node->hasAnother("type") || !node->hasAnother("bandwidth")) {

Callers

nothing calls this directly

Calls 4

getNextMethod · 0.80
c_strMethod · 0.80
elementMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected