static void to_base(person const & p, values & v, indicator & ind) { v.set("ID", p.id); v.set("FIRST_NAME", p.firstName); v.set("LAST_NAME", p.lastName); v.set("GENDER", p.gender, p.gender.empty() ? i_null : i_ok); ind = i_ok; }
static void from_base(values const &v, indicator &ind, domain::Corpus &p) { try { p.id = v.get<int>("id"); p.name = v.get<string>("name"); p.language = v.get<string>("language"); switch (v.get_properties("total_documents").get_data_type()) { case dt_integer: p.totalDocuments = v.get<int>("total_documents"); break; case dt_double: p.totalDocuments = v.get<double>("total_documents"); break; case dt_string: p.totalDocuments = atoll( v.get <string>("total_documents").c_str() ); break; case dt_unsigned_long_long: p.totalDocuments = v.get <unsigned long long>("total_documents"); break; default: p.totalDocuments = v.get <long long> ("total_documents"); break; } } catch (const boost::exception &ex) { BOOST_LOG_TRIVIAL(error) << "ConversionException Corpus"; } }
static void to_base(const slin::Link &p, values &v, indicator &ind) { v.set("id", p.m_id); v.set("title", p.Title); v.set("url", p.Url); v.set("description", p.Description); v.set("tags", slin::concatStrings(p.Tags, "\x91")); v.set("notes", slin::concatStrings(p.Notes, "\x91")); ind = i_ok; }
void checkThread(const int &threadNum, values valueOne, Image3d inImage, values valueZero, Image3d *outImage, values valueAny = values()) { int minDepth = threadNum * inImage.getDepth() / THREAD_NUMBER; int maxDepth = (1 + threadNum) * inImage.getDepth() / THREAD_NUMBER; if (threadNum == 0) minDepth += 2; if (threadNum == THREAD_NUMBER - 1) maxDepth -= 2; for (int i = minDepth; i < maxDepth; ++i) { for (int j = 2; j < inImage.getRows() - 2; ++j) { for (int k = 2; k < inImage.getCols() - 2; ++k) { if (inImage.getPoint(k, j, i) == 0) continue; bool found = false; for (auto one : valueOne) { if (inImage.getPoint(k + one[0], j + one[1], i + one[2]) == 0) { found = true; break; } } if (!found) { for (auto one : valueZero) { if (inImage.getPoint(k + one[0], j + one[1], i + one[2]) != 0) { found = true; break; } } } if (!found && !valueAny.empty()) { found = true; for (auto any : valueAny) { if (inImage.getPoint(k + any[0], j + any[1], i + any[2]) != 0) { found = false; break; } } } if (!found) { std::lock_guard<std::mutex> lock(Mutex); outImage->setPoint(k, j, i, 0); } } } } }
// ////////////////////////////////////////////////////////////////////// void type_conversion<OPENGEOPP::IPBlockRecord_T>:: to_base (const OPENGEOPP::IPBlockRecord_T& iIPBlockRecord, values& ioIPBlockRecordValues, indicator& ioIndicator) { const indicator lCountryCodeIndicator = iIPBlockRecord._country3Char.empty() ? i_null : i_ok; const indicator lCountryNameIndicator = iIPBlockRecord._country.empty() ? i_null : i_ok; ioIPBlockRecordValues.set ("ip_from", iIPBlockRecord._ipFrom); ioIPBlockRecordValues.set ("ip_to", iIPBlockRecord._ipTo); ioIPBlockRecordValues.set ("registry", iIPBlockRecord._registry); const int lAssignedDate = 1; // const int lAssignedDate = iIPBlockRecord._dateAssigned ioIPBlockRecordValues.set ("assigned_date", lAssignedDate); ioIPBlockRecordValues.set ("country_code2", iIPBlockRecord._country2Char); ioIPBlockRecordValues.set ("country_code3", iIPBlockRecord._country3Char, lCountryCodeIndicator); ioIPBlockRecordValues.set ("country_name", iIPBlockRecord._country, lCountryNameIndicator); ioIndicator = i_ok; }
const std::vector<InternalVector>& x() { return values_.x(); }
void statement_impl::bind(values & values) { std::size_t cnt = 0; try { for (std::vector<details::standard_use_type*>::iterator it = values.uses_.begin(); it != values.uses_.end(); ++it) { // only bind those variables which are: // - either named and actually referenced in the statement, // - or positional std::string const& useName = (*it)->get_name(); if (useName.empty()) { // positional use element int position = static_cast<int>(uses_.size()); (*it)->bind(*this, position); uses_.push_back(*it); indicators_.push_back(values.indicators_[cnt]); } else { // named use element - check if it is used std::string const placeholder = ":" + useName; std::size_t pos = query_.find(placeholder); while (pos != std::string::npos) { // Retrieve next char after placeholder // make sure we do not go out of range on the string const char nextChar = (pos + placeholder.size()) < query_.size() ? query_[pos + placeholder.size()] : '\0'; if (std::isalnum(nextChar)) { // We got a partial match only, // keep looking for the placeholder pos = query_.find(placeholder, pos + placeholder.size()); } else { int position = static_cast<int>(uses_.size()); (*it)->bind(*this, position); uses_.push_back(*it); indicators_.push_back(values.indicators_[cnt]); // Ok we found it, done break; } } // In case we couldn't find the placeholder if (pos == std::string::npos) { values.add_unused(*it, values.indicators_[cnt]); } } cnt++; } } catch (...) { for (std::size_t i = ++cnt; i != values.uses_.size(); ++i) { values.add_unused(values.uses_[i], values.indicators_[i]); } throw; } }
static void to_base(domain::Corpus &p, values &v, indicator &ind) { v.set("id", p.id); v.set("name", p.name); v.set("language", p.language); v.set("totalDocuments", p.totalDocuments); }
void statement_impl::bind(values & values) { std::size_t cnt = 0; try { for (std::vector<details::standard_use_type *>::iterator it = values.uses_.begin(); it != values.uses_.end(); ++it) { // only bind those variables which are: // - either named and actually referenced in the statement, // - or positional std::string const & useName = (*it)->get_name(); if (useName.empty()) { // positional use element int position = static_cast<int>(uses_.size()); (*it)->bind(*this, position); uses_.push_back(*it); indicators_.push_back(values.indicators_[cnt]); } else { // named use element - check if it is used const std::string placeholder = ":" + useName; std::size_t pos = query_.find(placeholder); if (pos != std::string::npos) { const char nextChar = query_[pos + placeholder.size()]; if (nextChar == ' ' || nextChar == ',' || nextChar == '\0' || nextChar == ')') { int position = static_cast<int>(uses_.size()); (*it)->bind(*this, position); uses_.push_back(*it); indicators_.push_back(values.indicators_[cnt]); } else { values.add_unused(*it, values.indicators_[cnt]); } } else { values.add_unused(*it, values.indicators_[cnt]); } } cnt++; } } catch (...) { for (std::size_t i = ++cnt; i != values.uses_.size(); ++i) { values.add_unused(values.uses_[i], values.indicators_[i]); } throw; } }