Skip to content

Commit 2444e17

Browse files
committed
Fixed #5 added setElementValue for bool, int, long
1 parent 251ea4c commit 2444e17

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

src/wsjcpp_yaml.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,39 @@ bool WsjcppYamlItem::setElementValue(
312312

313313
// ---------------------------------------------------------------------
314314

315+
bool WsjcppYamlItem::setElementValue(
316+
const std::string &sName,
317+
long nValue,
318+
WsjcppYamlQuotes nNameQuotes,
319+
WsjcppYamlQuotes nValueQuotes
320+
) {
321+
return setElementValue(sName, std::to_string(nValue), nNameQuotes, nValueQuotes);
322+
}
323+
324+
// ---------------------------------------------------------------------
325+
326+
bool WsjcppYamlItem::setElementValue(
327+
const std::string &sName,
328+
int nValue,
329+
WsjcppYamlQuotes nNameQuotes,
330+
WsjcppYamlQuotes nValueQuotes
331+
) {
332+
return setElementValue(sName, std::to_string(nValue), nNameQuotes, nValueQuotes);
333+
}
334+
335+
// ---------------------------------------------------------------------
336+
337+
bool WsjcppYamlItem::setElementValue(
338+
const std::string &sName,
339+
bool bValue,
340+
WsjcppYamlQuotes nNameQuotes,
341+
WsjcppYamlQuotes nValueQuotes
342+
) {
343+
return setElementValue(sName, (bValue ? "yes" : "no"), nNameQuotes, nValueQuotes);
344+
}
345+
346+
// ---------------------------------------------------------------------
347+
315348
bool WsjcppYamlItem::createElementMap(const std::string &sName, WsjcppYamlQuotes nNameQuotes) {
316349
if (m_nItemType != WSJCPP_YAML_ITEM_MAP ) {
317350
WsjcppLog::throw_err(TAG, "createElementMap, Element must be 'map' for " + this->getPlaceInFile().getForLogFormat());

src/wsjcpp_yaml.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,29 @@ class WsjcppYamlItem { // TODO: rename to node
9494
std::vector<std::string> getKeys();
9595

9696
bool setElementValue(
97-
const std::string &sName,
98-
const std::string &sValue,
97+
const std::string &sName, const std::string &sValue,
9998
WsjcppYamlQuotes nNameQuotes = WSJCPP_YAML_QUOTES_NONE,
10099
WsjcppYamlQuotes nValueQuotes = WSJCPP_YAML_QUOTES_NONE
101100
);
101+
102+
bool setElementValue(
103+
const std::string &sName, int nValue,
104+
WsjcppYamlQuotes nNameQuotes = WSJCPP_YAML_QUOTES_NONE,
105+
WsjcppYamlQuotes nValueQuotes = WSJCPP_YAML_QUOTES_NONE
106+
);
107+
108+
bool setElementValue(
109+
const std::string &sName, long nValue,
110+
WsjcppYamlQuotes nNameQuotes = WSJCPP_YAML_QUOTES_NONE,
111+
WsjcppYamlQuotes nValueQuotes = WSJCPP_YAML_QUOTES_NONE
112+
);
113+
114+
bool setElementValue(
115+
const std::string &sName, bool bValue,
116+
WsjcppYamlQuotes nNameQuotes = WSJCPP_YAML_QUOTES_NONE,
117+
WsjcppYamlQuotes nValueQuotes = WSJCPP_YAML_QUOTES_NONE
118+
);
119+
102120
bool createElementMap(const std::string &sName, WsjcppYamlQuotes nNameQuotes);
103121
WsjcppYamlItem *createElementMap();
104122
bool createElementArray(const std::string &sName, WsjcppYamlQuotes nNameQuotes);

0 commit comments

Comments
 (0)