// [[Rcpp::export]] Rcpp::List CPL_get_rgdal_drivers(int dummy) { int ndr = GetGDALDriverManager()->GetDriverCount(); Rcpp::CharacterVector name(ndr); Rcpp::CharacterVector long_name(ndr); Rcpp::LogicalVector create(ndr); Rcpp::LogicalVector copy(ndr); Rcpp::LogicalVector vattr(ndr); Rcpp::LogicalVector rattr(ndr); Rcpp::LogicalVector vsi_attr(ndr); for (int i = 0; i < ndr; i++) { GDALDriver *pDriver = GetGDALDriverManager()->GetDriver(i); name(i) = GDALGetDriverShortName( pDriver ); long_name(i) = GDALGetDriverLongName( pDriver ); create(i) = (pDriver->GetMetadataItem(GDAL_DCAP_CREATE) != NULL); copy(i) = (pDriver->GetMetadataItem(GDAL_DCAP_CREATECOPY) != NULL); vattr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_VECTOR) != NULL); rattr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_RASTER) != NULL); vsi_attr(i) = (pDriver->GetMetadataItem(GDAL_DCAP_VIRTUALIO) != NULL); } return Rcpp::DataFrame::create( Rcpp::Named("name") = name, Rcpp::Named("long_name") = long_name, Rcpp::Named("write") = create, Rcpp::Named("copy") = copy, Rcpp::Named("is_raster") = rattr, Rcpp::Named("is_vector") = vattr, Rcpp::Named("vsi") = vsi_attr); }
/// Formats the long name of the option for documentation purposes. /// /// \return A string describing the option's long name. std::string cmdline::base_option::format_long_name(void) const { if (needs_arg()) { return F("--%s=%s") % long_name() % arg_name(); } else { return F("--%s") % long_name(); } }
void InputParameters::checkParams(const std::string &prefix) { std::string l_prefix = this->have_parameter<std::string>("long_name") ? this->get<std::string>("long_name") : prefix; std::ostringstream oss; // Required parameters for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it) { if (!isParamValid(it->first) && isParamRequired(it->first)) { // The parameter is required but missing if (oss.str().empty()) oss << "The following required parameters are missing:" << std::endl; oss << l_prefix << "/" << it->first << std::endl; oss << "\tDoc String: \"" + getDocString(it->first) + "\"" << std::endl; } } // Range checked parameters for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it) { std::string long_name(l_prefix + "/" + it->first); dynamicCastRangeCheck(Real, Real, long_name, it->first, it->second, oss); dynamicCastRangeCheck(int, long, long_name, it->first, it->second, oss); dynamicCastRangeCheck(long, long, long_name, it->first, it->second, oss); dynamicCastRangeCheck(unsigned int, long, long_name, it->first, it->second, oss); } if (!oss.str().empty()) mooseError(oss.str()); }
void AddVariableAction::createInitialConditionAction() { // Variable name std::string var_name = getShortName(); // Create the object name std::string long_name("ICs/"); long_name += var_name; long_name += "_moose"; // Set the parameters for the action InputParameters action_params = _action_factory.getValidParams("AddOutputAction"); action_params.set<ActionWarehouse *>("awh") = &_awh; if (_scalar_var) action_params.set<std::string>("type") = "ScalarConstantIC"; else action_params.set<std::string>("type") = "ConstantIC"; // Create the action MooseSharedPointer<MooseObjectAction> action = MooseSharedNamespace::static_pointer_cast<MooseObjectAction>(_action_factory.create("AddInitialConditionAction", long_name, action_params)); // Set the required parameters for the object to be created action->getObjectParams().set<VariableName>("variable") = var_name; action->getObjectParams().set<Real>("value") = getParam<Real>("initial_condition"); // Store the action in the ActionWarehouse _awh.addActionBlock(action); }
static char * program_name(HANDLE hInstance) { char program[MAXPATHLEN]; GetModuleFileName(hInstance, program, sizeof(program)); long_name(program); return strcpy(malloc(strlen(program)+1), program); }
/// Ensures that an integer argument passed to the int_option is valid. /// /// \param raw_value The argument representing an integer as provided by the /// user. /// /// \throw cmdline::option_argument_value_error If the integer provided in /// raw_value is invalid. void cmdline::int_option::validate(const std::string& raw_value) const { try { (void)text::to_type< int >(raw_value); } catch (const std::runtime_error& e) { throw cmdline::option_argument_value_error( F("--%s") % long_name(), raw_value, "Not a valid integer"); } }
/// Ensures that a path argument passed to the path_option is valid. /// /// \param raw_value The argument representing a path as provided by the user. /// /// \throw cmdline::option_argument_value_error If the path provided in /// raw_value is invalid. void cmdline::path_option::validate(const std::string& raw_value) const { try { (void)utils::fs::path(raw_value); } catch (const utils::fs::error& e) { throw cmdline::option_argument_value_error(F("--%s") % long_name(), raw_value, e.what()); } }
/// Validates the argument to a property option. /// /// \param raw_value The argument provided by the user. void cmdline::property_option::validate(const std::string& raw_value) const { const std::string::size_type pos = raw_value.find('='); if (pos == std::string::npos) throw cmdline::option_argument_value_error( F("--%s") % long_name(), raw_value, F("Argument does not have the form '%s'") % arg_name()); const std::string key = raw_value.substr(0, pos); if (key.empty()) throw cmdline::option_argument_value_error( F("--%s") % long_name(), raw_value, "Empty property name"); const std::string value = raw_value.substr(pos + 1); if (value.empty()) throw cmdline::option_argument_value_error( F("--%s") % long_name(), raw_value, "Empty value"); }
void InputParameters::checkParams(const std::string & parsing_syntax) { std::string l_prefix = this->have_parameter<std::string>("_object_name") ? this->get<std::string>("_object_name") : parsing_syntax; std::ostringstream oss; // Required parameters for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it) { if (!isParamValid(it->first) && isParamRequired(it->first)) { // The parameter is required but missing if (oss.str().empty()) oss << "The following required parameters are missing:" << std::endl; oss << l_prefix << "/" << it->first << std::endl; oss << "\tDoc String: \"" + getDocString(it->first) + "\"" << std::endl; } } // Range checked parameters for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it) { std::string long_name(l_prefix + "/" + it->first); dynamicCastRangeCheck(Real, Real, long_name, it->first, it->second, oss); dynamicCastRangeCheck(int, long, long_name, it->first, it->second, oss); dynamicCastRangeCheck(long, long, long_name, it->first, it->second, oss); dynamicCastRangeCheck(unsigned int, long, long_name, it->first, it->second, oss); } if (!oss.str().empty()) mooseError(oss.str()); // Controllable parameters for (std::set<std::string>::const_iterator it = _controllable_params.begin(); it != _controllable_params.end(); ++it) { // Check that parameter is valid if (!isParamValid(*it)) mooseError("The parameter '" << *it << "' is not a valid parameter for the object " << l_prefix << " thus cannot be marked as controllable."); if (isPrivate(*it)) mooseError("The parameter, '" << *it << "', in " << l_prefix << " is a private parameter and cannot be marked as controllable"); checkMooseType(NonlinearVariableName, *it); checkMooseType(AuxVariableName, *it); checkMooseType(VariableName, *it); checkMooseType(BoundaryName, *it); checkMooseType(SubdomainName, *it); checkMooseType(PostprocessorName, *it); checkMooseType(VectorPostprocessorName, *it); checkMooseType(UserObjectName, *it); checkMooseType(MaterialPropertyName, *it); } }
void CommonOutputAction::create(std::string object_type) { // Set the 'type =' parameters for the desired object _action_params.set<std::string>("type") = object_type; // Create the complete object name (use lower case for the object_name) std::transform(object_type.begin(), object_type.end(), object_type.begin(), ::tolower); std::string long_name("Outputs/"); long_name += object_type; // Create the action MooseObjectAction * action = static_cast<MooseObjectAction *>(_action_factory.create("AddOutputAction", long_name, _action_params)); // Add the action to the warehouse _awh.addActionBlock(action); }
void CommonOutputAction::createAutoRecoveryCheckpointObject() { // Set the 'type =' parameters for the desired object _action_params.set<std::string>("type") = "Checkpoint"; // Create the complete object name (use lower case for the object_name) std::string long_name("Outputs/auto_recovery_checkpoint"); // Create the action MooseObjectAction * action = static_cast<MooseObjectAction *>(_action_factory.create("AddOutputAction", long_name, _action_params)); // Set the suffix for the auto recovery checkpoint output so when recovering the location is known action->getObjectParams().set<std::string>("suffix") = "auto_recovery"; // Add the action to the warehouse _awh.addActionBlock(action); }
static void update_alsa_device(char *path, char *shortname) { struct device_data *ptr; FILE *file; char fullpath[4096]; char name[4096]; ptr = devices; sprintf(fullpath, "%s/power_off_acct", path); if (access(fullpath, R_OK)) return; while (ptr) { if (strcmp(ptr->pathname, path)==0) { file = fopen(fullpath, "r"); if (!file) return; fgets(name, 4096, file); ptr->power_off = strtoull(name, NULL, 10); fclose(file); sprintf(fullpath, "%s/power_on_acct", path); file = fopen(fullpath, "r"); if (!file) return; fgets(name, 4096, file); ptr->power_on = strtoull(name, NULL, 10); fclose(file); return; } ptr = ptr->next; } /* no luck, new one */ ptr = malloc(sizeof(struct device_data)); assert(ptr!=0); memset(ptr, 0, sizeof(struct device_data)); ptr->next = devices; devices = ptr; strcpy(ptr->pathname, path); strcpy(ptr->human_name, long_name(path, shortname)); }
void CommonOutputAction::create(std::string object_type) { // Set the 'type =' parameters for the desired object _action_params.set<std::string>("type") = object_type; // Create the complete object name (uses lower case of type) std::transform(object_type.begin(), object_type.end(), object_type.begin(), ::tolower); std::string long_name("Outputs/"); long_name += object_type; // Create the action MooseSharedPointer<MooseObjectAction> action = MooseSharedNamespace::static_pointer_cast<MooseObjectAction>(_action_factory.create("AddOutputAction", long_name, _action_params)); // Set flag indicating that the object to be created was created with short-cut syntax action->getObjectParams().set<bool>("_built_by_moose") = true; // Add the action to the warehouse _awh.addActionBlock(action); }
string_type singular() const { return string_type(long_name(typename Period::type()), 0, long_name(typename Period::type()).size()-1); }
int act_debug(Object * obj, char *name) { table_act(table_debug, obj, long_name(table_debug, name)); return 1; }
string_type plural() const {return long_name(typename Period::type());}
static std::basic_string<CharT> short_name() {return long_name();}
static std::basic_string<CharT> prefix() {return long_name();}
static std::wstring prefix() {return long_name();}
std::string SyntaxTree::TreeNode::print(short depth, const std::string &search_string, bool &found) { std::string doc; std::string long_name(getLongName()); std::string name(_syntax_tree.isLongNames() ? long_name : _name); std::string out; if (depth < 0) { for (const auto & c_it : _children) { bool local_found = false; std::string local_out (c_it.second->print(depth+1, search_string, local_found)); found |= local_found; // Update the current frame's found variable if (local_found) out += local_out; } return out; } // GlobalParamsAction is special - we need to just always print it out // if (_name == "GlobalParamsAction") // found = true; std::string indent((depth+1)*2, ' '); std::multimap<std::string, InputParameters *>::const_iterator it = _moose_object_params.begin(); do { bool local_found = false; std::string local_out; // Compare the block name, if it's matched we are going to pass an empty search string // which means match ALL parameters std::string local_search_string; if (wildCardMatch(name, search_string)) found = true; else local_search_string = search_string; if (it != _moose_object_params.end()) doc = it->second->getClassDescription(); else doc = ""; local_out += _syntax_tree.printBlockOpen(name, depth, doc); for (const auto & a_it : _action_params) if (a_it.first != "EmptyAction") { local_out += _syntax_tree.printParams(name, long_name, *(a_it.second), depth, local_search_string, local_found); found |= local_found; // Update the current frame's found variable //DEBUG // Moose::out << "\n" << indent << "(" << ait->first << ")"; //DEBUG } if (it != _moose_object_params.end()) { local_out += _syntax_tree.printParams(name, long_name, *it->second, depth, local_search_string, local_found); found |= local_found; //DEBUG // Moose::out << "\n" << indent << "{" << it->first << "}"; //DEBUG } local_out += _syntax_tree.preTraverse(depth); for (const auto & c_it : _children) { bool child_found = false; std::string child_out (c_it.second->print(depth+1, local_search_string, child_found)); found |= child_found; // Update the current frame's found variable if (child_found) local_out += child_out; } local_out += _syntax_tree.printBlockClose(name, depth); if (found) out += local_out; // If there are no moose object params then we have to be careful about how we // increment the iterator. We only want to increment if we aren't already // at the end. } while (it != _moose_object_params.end() && ++it != _moose_object_params.end()); return out; }
res::path Entity::full_name() const { return m_classPath.parent() / long_name(); }