本文整理汇总了C++中StringView::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ StringView::getData方法的具体用法?C++ StringView::getData怎么用?C++ StringView::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringView
的用法示例。
在下文中一共展示了StringView::getData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSubs
/**
* @brief Returns all sub-configuration with given name.
*
* @param name Sub-configuration name.
*
* @return
*/
DynamicArray<UniquePtr<config::Implementation>> getSubs(StringView name) const noexcept override
{
DynamicArray<UniquePtr<config::Implementation>> res;
// Foreach children
for (const auto& node : m_node.children(name.getData()))
res.push_back(makeUnique<ConfigImplementation>(node.internal_object()));
return res;
}
示例2: changeMoleculeCount
/**
* @brief Add molecules of given name.
*
* @param name Molecule name.
* @param diff Number of molecules.
*/
void changeMoleculeCount(const StringView& name, MoleculeCountDifference diff) noexcept
{
// Get mutable reference
auto& value = m_molecules[name.getData()];
// We need to compare signed versions.
// If not, this condition is always true.
if (MoleculeCountDifference(value) + diff < 0)
value = MoleculeCount(0);
else
value += diff;
}
示例3: has
/**
* @brief Check if value with given name exists.
*
* @param name Value name.
*
* @return
*/
bool has(StringView name) const noexcept override
{
return !m_node.attribute(name.getData()).empty();
}
示例4: addSub
/**
* @brief Create new sub-configuration.
*
* @param name Sub-configuration name.
*
* @return
*/
UniquePtr<config::Implementation> addSub(StringView name) noexcept override
{
return makeUnique<ConfigImplementation>(m_node.append_child(name.getData()));
}
示例5: setContent
/**
* @brief Store content.
*
* @param content Content text.
*/
void setContent(StringView content) noexcept override
{
m_node.text().set(content.getData());
}
示例6: set
/**
* @brief Set string value.
*
* @param name Value name.
* @param value Value to store.
*
* @return
*/
void set(StringView name, StringView value) noexcept override
{
m_node.attribute(name.getData()).set_value(value.getData());
}
示例7: hasSubs
/**
* @brief Returns if sub-configuration exists.
*
* @param name Sub-configuration name.
*
* @return
*/
bool hasSubs(StringView name) const noexcept override
{
auto rng = m_node.children(name.getData());
return rng.begin() != rng.end();
}
示例8: get
/**
* @brief Returns string value.
*
* @param name Value name.
*
* @return
*/
String get(StringView name) const noexcept override
{
return m_node.attribute(name.getData()).value();
}
示例9: setMoleculeCount
/**
* @brief Set a number of molecules of given name.
*
* @param name Molecule name.
* @param count Number of molecules.
*/
void setMoleculeCount(const StringView& name, MoleculeCount count) noexcept
{
m_molecules[name.getData()] = count;
}
示例10: getMoleculeCount
/**
* @brief Returns a number moulecules of given name.
*
* @param name Molecule name.
*
* @return Number of molecules.
*/
MoleculeCount getMoleculeCount(const StringView& name) const noexcept
{
auto it = m_molecules.find(name.getData());
return it != m_molecules.end() ? it->second : MoleculeCount();
}
示例11: string
TEST(StringViewTests, stdStringConstructor) {
std::string string("ABCD");
const StringView view = string;
ASSERT_EQ(string.data(), view.getData());
ASSERT_EQ(string.size(), view.getSize());
}
示例12:
TEST(StringViewTests, arrayConstructor) {
const char data[] = "ABCD";
const StringView view = data;
ASSERT_EQ(data, view.getData());
ASSERT_EQ(4, view.getSize());
}