186 return Add(strNumbers.
Get());
189 bool OTNumList::Add(
const std::string& strNumbers)
194 return Add(strNumbers.c_str());
201 bool OTNumList::Add(
const char* szNumbers)
207 bool bSuccess =
true;
209 const char* pChar = szNumbers;
213 while (std::isspace(*pChar, loc)) pChar++;
215 bool bStartedANumber =
224 if (std::isdigit(*pChar, loc)) {
225 bStartedANumber =
true;
227 int32_t nDigit = (*pChar -
'0');
233 else if ((
',' == *pChar) || (
'\0' == *pChar) ||
234 std::isspace(*pChar, loc))
238 if ((lNum > 0) || (bStartedANumber && (0 == lNum))) {
249 bStartedANumber =
false;
252 otErr <<
"OTNumList::Add: Error: Unexpected character found in "
253 "erstwhile comma-separated list of longs: " << *pChar
260 if (
'\0' == *pChar)
break;
265 while (std::isspace(*pChar, loc)) pChar++;
272 bool OTNumList::Add(
const int64_t& theValue)
275 auto it = m_setData.find(theValue);
277 if (m_setData.end() == it)
279 m_setData.insert(theValue);
287 auto it = m_setData.begin();
289 if (m_setData.end() != it)
299 auto it = m_setData.begin();
301 if (m_setData.end() != it)
312 auto it = m_setData.find(theValue);
314 if (m_setData.end() != it)
326 auto it = m_setData.find(theValue);
328 return (m_setData.end() == it) ?
false :
true;
337 bool bSuccess =
true;
339 for (
const auto& it : theNumbers) {
358 for (
auto& it : m_setData) {
359 if (!rhs.
Verify(it))
return false;
376 for (
const auto& it : m_setData) {
377 auto it_find = setData.find(it);
379 if (it_find != setData.end())
390 std::set<int64_t> theOutput;
391 theNumList.
Output(theOutput);
393 return Add(theOutput);
396 bool OTNumList::Add(
const std::set<int64_t>& theNumbers)
401 bool bSuccess =
true;
403 for (
const auto& it : theNumbers) {
417 bool bSuccess =
true;
419 for (
const auto& it : theNumbers) {
434 theOutput = m_setData;
436 return !m_setData.empty();
444 int32_t nIterationCount = 0;
446 for (
auto& it : m_setData) {
449 strOutput.Concatenate(
454 (1 == nIterationCount) ?
"" :
",", it);
457 return !m_setData.empty();
462 return static_cast<int32_t
>(m_setData.size());
EXPORT bool Remove(const int64_t &theValue)
EXPORT bool Peek(int64_t &lPeek) const
EXPORT bool Output(std::set< int64_t > &theOutput) const
EXPORT int32_t Count() const
EXPORT const char * Get() const
OTLOG_IMPORT OTLogStream otErr
EXPORT bool VerifyAny(const OTNumList &rhs) const
EXPORT bool Verify(const int64_t &theValue) const