mirror of https://github.com/kiwix/libkiwix.git
Non-throwing Book::getDefaultIllustration()
This commit is contained in:
parent
c8da5eea2b
commit
8a6adddc16
|
@ -143,6 +143,10 @@ class Book
|
||||||
bool m_readOnly = false;
|
bool m_readOnly = false;
|
||||||
uint64_t m_size = 0;
|
uint64_t m_size = 0;
|
||||||
std::vector<std::shared_ptr<Illustration>> m_illustrations;
|
std::vector<std::shared_ptr<Illustration>> m_illustrations;
|
||||||
|
|
||||||
|
// Used as the return value of getDefaultIllustration() when no default
|
||||||
|
// illustration is found in the book
|
||||||
|
static const Illustration missingDefaultIllustration;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,8 @@ void Book::setPath(const std::string& path)
|
||||||
: path;
|
: path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Book::Illustration Book::missingDefaultIllustration;
|
||||||
|
|
||||||
const Book::Illustration& Book::getDefaultIllustration() const
|
const Book::Illustration& Book::getDefaultIllustration() const
|
||||||
{
|
{
|
||||||
for ( const auto& ilPtr : m_illustrations ) {
|
for ( const auto& ilPtr : m_illustrations ) {
|
||||||
|
@ -238,7 +240,7 @@ const Book::Illustration& Book::getDefaultIllustration() const
|
||||||
return *ilPtr;
|
return *ilPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw std::runtime_error("No default illustration");
|
return missingDefaultIllustration;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& Book::Illustration::getData() const
|
const std::string& Book::Illustration::getData() const
|
||||||
|
|
Loading…
Reference in New Issue