bool Property::ParseMetaElement(shared_ptr<xml::Node> node) { if ( !bool(node) ) return false; if ( !node->IsElementNode() ) return false; auto ns = node->Namespace(); if ( ns != nullptr && ns->URI() == DCMES_uri ) { auto found = NameToIDMap.find(node->Name()); if ( found == NameToIDMap.end() ) return false; _type = found->second; _identifier = IRI(string(DCMES_uri) + node->Name()); _value = node->Content(); _language = node->Language(); SetXMLIdentifier(_getProp(node, "id")); return true; } else if ( node->Name() == MetaTagName ) { string property = _getProp(node, "property"); if ( property.empty() ) return false; _type = DCType::Custom; _identifier = OwnedBy::Owner()->PropertyIRIFromString(property); _value = node->Content(); _language = node->Language(); SetXMLIdentifier(_getProp(node, "id")); return true; } else if ( ns != nullptr ) { _type = DCType::Custom; _identifier = IRI(string(ns->URI()) + node->Name()); _value = node->Content(); _language = node->Language(); SetXMLIdentifier(_getProp(node, "id")); return true; } return false; }
void FieldGenerator::signal_update(Common::SignalArgs& node) { Component::Ptr mesh_component = access_component_ptr(URI(option("Mesh").value_str())); if(!mesh_component) throw ValueNotFound(FromHere(), "The path for the mesh is incorrect"); CMesh::Ptr mesh = boost::dynamic_pointer_cast<CMesh>(mesh_component); if(!mesh) throw BadValue(FromHere(), "The given path does not point to a mesh"); const std::string field_name = option("FieldName").value_str(); const std::string var_name = option("VariableName").value_str(); const Real value = option("Value").value<Real>(); // Get the field, if it exists CField::Ptr field = boost::dynamic_pointer_cast<CField>(mesh->get_child_ptr(field_name)); // We can update the field if it exists AND contains the variable that we need if(field && !field->has_variable(var_name)) { throw ValueExists(FromHere(), "A field with name " + field_name + " already exists, but it does not contain a variable named " + var_name); } // If the field didn't exist, we create it if(!field) { mesh->create_scalar_field(field_name, var_name, CF::Mesh::CField::Basis::POINT_BASED); } // Proto placeholder MeshTerm<0, ScalarField> s(field_name, var_name); // Update the field value for_each_node(mesh->topology(), s = value); }
URI NLink::target_path() const { if(m_target.get() == nullptr) return URI(); return m_target->uri(); }
URI URI::fromString(const std::string& string) { URI uri; const auto firstColon = string.find_first_of(':'); const auto secondColon = string.find_first_of(':', firstColon + 1); const auto firstSlash = string.find_first_of('/'); const auto secondSlash = string.find_first_of('/', firstSlash + 1); const auto thirdSlash = string.find_first_of('/', secondSlash + 1); if (firstColon == std::string::npos || firstSlash == std::string::npos || secondSlash == std::string::npos || thirdSlash == std::string::npos) { return URI(); } uri.protocol_ = string.substr(0, firstColon); uri.server_ = string.substr(secondSlash + 1, std::min(secondColon, thirdSlash) - secondSlash - 1); if (secondColon < thirdSlash) { const auto portString = string.substr(secondColon + 1, thirdSlash - secondColon - 1); uri.port_ = std::stoul(portString); } else { if (uri.protocol_ == "coap") uri.port_ = 5683; if (uri.protocol_ == "coaps") uri.port_ = 20220; } uri.path_ = string.substr(thirdSlash); uri.isValid_ = true; return uri; }
BinaryDataWriter::BinaryDataWriter ( const std::string& name ) : Component(name) { options().add("file", URI()) .pretty_name("File") .description("File name for the output file") .attach_trigger(boost::bind(&BinaryDataWriter::trigger_file, this)); }
NS_IMETHODIMP nsInputStreamChannel::SetURI(nsIURI *uri) { NS_ENSURE_TRUE(!URI(), NS_ERROR_ALREADY_INITIALIZED); nsBaseChannel::SetURI(uri); return NS_OK; }
void FileNameHandler::finishedDownload(const NameLookupHandler::Callback &cb, const std::string &filename, DenseDataPtr data, bool success) { bool exists = false; RemoteFileId foundURI; if (success) { for (const unsigned char *iter = data->begin(); iter != data->end();) { const unsigned char *newlinepos = std::find(iter, data->end(), '\n'); if (newlinepos == data->end()) { break; } const unsigned char *spacepos = std::find(iter, newlinepos, ' '); if (std::string(iter, spacepos) != filename) { iter = newlinepos + 1; continue; } if (spacepos == newlinepos || spacepos + 1 == newlinepos) { // the name does not exist. exists = false; } else { exists = true; foundURI = RemoteFileId(URI(std::string(spacepos+1, newlinepos))); } iter = newlinepos + 1; } } if (exists) { cb(foundURI.fingerprint(), foundURI.uri().toString(), true); } else { cb(Fingerprint::null(), std::string(), false); } }
PRBool nsGopherChannel::GetStatusArg(nsresult status, nsString &statusArg) { nsCAutoString host; URI()->GetHost(host); CopyUTF8toUTF16(host, statusArg); return PR_TRUE; }
bool nsFtpChannel::GetStatusArg(nsresult status, nsString &statusArg) { nsCAutoString host; URI()->GetHost(host); CopyUTF8toUTF16(host, statusArg); return true; }
virtual boost::shared_ptr< Option > create_option(const std::string& name, const boost::any& default_value) { const std::vector<std::string> uri_strings = boost::any_cast< std::vector<std::string> >(default_value); typename OptionArray< Handle<CTYPE> >::value_type def_val; def_val.reserve(uri_strings.size()); BOOST_FOREACH(const std::string& uri_str, uri_strings) { def_val.push_back(Handle<CTYPE>(Core::instance().root().access_component(URI(uri_str)))); }
//------------------------------------------------------------------------------ ofxHTTPBaseRequest::ofxHTTPBaseRequest(const string& _httpMethod, const string& _uri, const string& _httpVersion) : httpMethod(_httpMethod), httpVersion(_httpVersion) { // this is kind of a mess, but we want to create requests from string uris try { uri = URI(_uri); bHasValidURI = true; } catch(const SyntaxException& exc) { invalidURI = _uri; uri = URI("http://127.0.0.1"); bHasValidURI = false; ofLogError("ofxHTTPBaseRequest::ofxHTTPBaseRequest") << "Syntax exeption: " << exc.message() << " Setting uri to http://127.0.0.1"; } setFormFieldsFromURI(uri); }
void IterativeSolver::raise_iteration_done() { SignalOptions opts; const Uint iter = properties().value<Uint>("iteration"); opts.add_option< OptionT<Uint> >( "iteration", iter ); SignalFrame frame = opts.create_frame("iteration_done", uri(), URI()); Common::Core::instance().event_handler().raise_event( "iteration_done", frame); }
NS_IMETHODIMP nsFileChannel::GetFile(nsIFile **file) { nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(URI()); NS_ENSURE_STATE(fileURL); // This returns a cloned nsIFile return fileURL->GetFile(file); }
bool ARTSPConnection::receiveRTSPRequest() { AString requestLine; LOGI(LOG_TAG,"start receiveLine ......\n"); if (!receiveLine(&requestLine)) { return false; } // LOGI(LOG_TAG,"receiveLine OK\n"); sp<AMessage> request = new AMessage(kWhatRequest,mhandlerID); request->setInt32("SessionID",mSessionID); LOGI(LOG_TAG,"request->setInt32 SessionID %d\n",mSessionID); LOGI(LOG_TAG,"request: %s\n", requestLine.c_str()); ssize_t space1 = requestLine.find(" ");//寻找空格 if (space1 < 0) { return false; } ssize_t space2 = requestLine.find(" ", space1 + 1); if (space2 < 0) { return false; } AString Method(requestLine.c_str(), space1); request->setString("Method",Method.c_str()); AString URI(requestLine,space1+1,space2-space1-1); request->setString("URI",URI.c_str()); AString line; for (;;) { if (!receiveLine(&line)) { break; } if (line.empty()) { break; } ssize_t colonPos = line.find(":"); if (colonPos < 0) { // Malformed header line. return false; } AString key(line, 0, colonPos); key.trim(); // key.tolower(); line.erase(0, colonPos + 1); line.trim(); LOGI(LOG_TAG,"line: %s:%s\n", key.c_str(),line.c_str()); request->setString(key.c_str(),line.c_str()); } LOGI(LOG_TAG,"Post the request to handler\n"); request->post();//将请求消息发送给uplayer 处理 return OK; }
CSetFieldValues::CSetFieldValues ( const std::string& name ) : CLoopOperation(name) { // options m_options.add_option< OptionURI > ("Field", URI("cpath:")) ->description("Field to set") ->mark_basic() ->attach_trigger ( boost::bind ( &CSetFieldValues::config_field, this ) ) ->cast_to<OptionURI>()->supported_protocol( URI::Scheme::CPATH ); }
void MeerkatChunkHandler::get(std::tr1::shared_ptr<Chunk> chunk, ChunkCallback callback) { std::tr1::shared_ptr<DenseData> bad; if (!chunk) { SILOG(transfer, error, "HttpChunkHandler get called with null chunk parameter"); callback(bad); return; } //Check to see if it's in the cache first SharedChunkCache::getSingleton().getCache()->getData(chunk->getHash(), chunk->getRange(), std::tr1::bind( &MeerkatChunkHandler::cache_check_callback, this, _1, URI("meerkat:///"), chunk, callback)); }
/* Parses the http request and responds accordingly to * the connected client. Jumps out of the routine if * there are errors during the transactions with the client. * * @param client_socket file descriptor of the client socket * @param error_jmp safe state to jump back to after encountering errors */ void ad_server_answer(int client_socket, jmp_buf error_jmp) { int requested_file; char path[512]; char buffer[AD_HTTP_REQUEST_MAX_SIZE]; ad_http_request *http_request = NULL; ad_response_receive(client_socket, buffer, AD_HTTP_REQUEST_MAX_SIZE, error_jmp); http_request = ad_http_request_parse(buffer); if (http_request == NULL || METHOD(http_request) == NULL || !ad_method_is_valid(METHOD(http_request))) { ad_http_request_free(http_request); ad_response_send(client_socket, AD_RESPONSE_CLIENT_BAD_REQUEST, error_jmp); } else if (ad_utils_strcmp_ic(METHOD(http_request), "GET")) { ad_http_request_free(http_request); ad_response_send(client_socket, AD_RESPONSE_SERVER_NOT_IMPLEMENTED, error_jmp); } else if (!ad_utils_strcmp_ic(METHOD(http_request),"GET")) { sprintf(path, "htdocs%s", URI(http_request)); if (ad_utils_is_directory(path)) { strcat(path, "index.html"); } ad_http_request_free(http_request); if ((requested_file = open(path, O_RDONLY)) == -1) { perror(path); ad_response_send(client_socket, AD_RESPONSE_CLIENT_NOT_FOUND, error_jmp); } else { ad_response_send(client_socket, AD_RESPONSE_HTTP_OK, error_jmp); ad_response_sendfile(client_socket, requested_file, error_jmp); close(requested_file); } } shutdown(client_socket, SHUT_WR); ad_response_receive(client_socket, buffer, AD_HTTP_REQUEST_MAX_SIZE, error_jmp); close(client_socket); }
void Synchro::FirstSynchro() { GetJSON(); std::map<int, Folder *> FolderMap = myparse.getFoldermap(); typedef std::map<int, Folder *>::iterator it_type2; for (it_type2 iterator = FolderMap.begin(); iterator != FolderMap.end(); iterator++) { Folder *fold = iterator->second; std::string str = this->folder + fold->getChosenPath() + "/" + fold->getName(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); if (QDir(cstr).exists() == true) return; else QDir().mkdir(cstr); delete[] cstr; } std::map<int, File *> fileMap = myparse.getFileMap(); std::string StrignUpload = "uploads/"; typedef std::map<int, File *>::iterator it_type; for (it_type iterator = fileMap.begin(); iterator != fileMap.end(); iterator++) { File *test = iterator->second; std::string urltodown = this->URL + StrignUpload + test->getPseudoOwner() + "/" + test->getRealPath() + test->getPath(); while (urltodown.find('\\') != std::string::npos) replace(urltodown, "\\", "/"); char *cstr1 = new char[urltodown.length() + 1]; strcpy(cstr1, urltodown.c_str()); std::string str = test->getName() + "." + test->getMimeType(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); str = this->folder + test->getChosenPath() + "/"; char *pathDisk = new char[str.length() + 1]; strcpy(pathDisk, str.c_str()); std::string ty = pathDisk + str; QString URI(ty.c_str()); DownloadFile(cstr1, URI); delete[] cstr; delete[] cstr1; } char acsjson[1024]; strcpy(acsjson, this->folder); strcat(acsjson, ".acsilserver"); QFile txt(acsjson); txt.open(QIODevice::ReadWrite | QIODevice::Text); txt.write(myparse.getJSON().c_str()); txt.close(); }
BinaryDataReader::BinaryDataReader ( const std::string& name ) : Component(name) { options().add("file", URI()) .pretty_name("File") .description("File name for the output file") .attach_trigger(boost::bind(&BinaryDataReader::trigger_file, this)); options().add("rank", common::PE::Comm::instance().rank()) .pretty_name("Rank") .description("Rank for which to read data") .attach_trigger(boost::bind(&BinaryDataReader::trigger_file, this)); }
URI BlueConfig::getReportSource(const std::string& report) const { std::string format = get(CONFIGSECTION_REPORT, report, BLUECONFIG_REPORT_FORMAT_KEY); if (format.empty()) { LBWARN << "Invalid or missing report: " << report << std::endl; return URI(); } boost::algorithm::to_lower(format); if (format == "binary" || format == "bin") return URI(std::string("file://") + _impl->getOutputRoot() + "/" + report + ".bbp"); if (format == "hdf5" || format.empty() || fs::is_directory(format)) return URI(std::string("file://") + _impl->getOutputRoot() + "/" + report + ".h5"); return URI(_impl->getOutputRoot()); }
EXPORT_C TBool CSenNamespace::Compare(const TDesC8& aOtherPrefix, const TDesC8& aOtherUri) const { TBool retVal(EFalse); if (aOtherUri == URI()) { if (aOtherPrefix == KNullDesC8 || aOtherPrefix == Prefix()) { retVal = ETrue; } } return retVal; }
void gotNameLookup(const Callback &cb, const URI &origNamedUri, ServiceIterator *services, const Fingerprint &hash, const std::string &str, bool success) { if (!success) { doNameLookup(cb, origNamedUri, services, ServiceIterator::GENERAL_ERROR); return; } services->finished(ServiceIterator::SUCCESS); RemoteFileId rfid(hash, URI(origNamedUri.context(), str)); addToCache(origNamedUri, rfid); cb(origNamedUri, &rfid); }
URI BlueConfig::getProjectionSource(const std::string& name) const { std::string path = get(CONFIGSECTION_PROJECTION, name, BLUECONFIG_PROJECTION_PATH_KEY); if (path.empty()) { LBWARN << "Invalid or missing projection " << name << std::endl; return URI(); } URI uri; uri.setScheme("file"); uri.setPath(path); return uri; }
CComputeArea::CComputeArea ( const std::string& name ) : CLoopOperation(name) { // options /// @todo make this option a OptionComponent m_options.add_option(OptionURI::create(Mesh::Tags::area(), URI("cpath:"), URI::Scheme::CPATH) ) ->description("Field to set") ->pretty_name("Area") ->mark_basic() ->attach_trigger ( boost::bind ( &CComputeArea::config_field, this ) ) ->add_tag(Mesh::Tags::area()); m_options["elements"].attach_trigger ( boost::bind ( &CComputeArea::trigger_elements, this ) ); }
URIResult URIHandler::ParseURL(const wxString &URL) { wxURI URI(URL); if (!URI.HasServer()) { return URI_BADDOMAIN; } m_Server = URI.GetServer(); if (!URI.HasPath()) { return URI_BADPATH; } m_Path = URI.GetPath(); // We support searching directories for files, this will be used later on wxInt32 FilePosition = (m_Path.Find(wxT('/'), true) + 1); if (FilePosition >= m_Path.Length()) { if (m_File == wxT("")) return URI_BADFILE; } // Save the directory as well m_Directory = m_Path.Mid(0, FilePosition - 1); if (m_File == wxT("")) m_File = m_Path.Mid(FilePosition); if (URI.HasPort()) m_Port = wxAtoi(URI.GetPort()); if (URI.HasUserInfo()) { wxString UserInfo = URI.GetUserInfo(); // These are deprecated as of RFC 1396 m_User = URI.GetUser(); if (UserInfo.Find(wxT(':'), false) != -1) m_Password = URI.GetPassword(); } return URI_SUCCESS; }
ComputeArea::ComputeArea ( const std::string& name ) : LoopOperation(name) { // options /// @todo make this option a OptionComponent options().add_option(mesh::Tags::area(), URI()) .supported_protocol(URI::Scheme::CPATH) .description("Field to set") .pretty_name("Area") .mark_basic() .attach_trigger ( boost::bind ( &ComputeArea::config_field, this ) ) .add_tag(mesh::Tags::area()); options()["elements"].attach_trigger ( boost::bind ( &ComputeArea::trigger_elements, this ) ); }
// static void CRDFParser::NameSpaceHandler(void * pGraph, raptor_namespace * pNameSpace) { const unsigned char * pURI = raptor_uri_as_string(raptor_namespace_get_uri(pNameSpace)); std::string URI(""); if (pURI) URI = (const char *) pURI; const unsigned char * pPrefix = raptor_namespace_get_prefix(pNameSpace); std::string Prefix(""); if (pPrefix) Prefix = (const char *) pPrefix; static_cast<CRDFGraph *>(pGraph)->addNameSpace(Prefix, URI); }
CLoopOperation::CLoopOperation ( const std::string& name ) : Common::CAction(name), m_can_start_loop(true), m_call_config_elements(true), m_idx(0) { // Following option is ignored if the loop is not about elements //m_options.add_option(OptionComponent<Mesh::CEntities>::create("Elements","Elements that are being looped",&m_elements)); m_options.add_option(OptionURI::create("Elements", URI("cpath:"), URI::Scheme::CPATH)) ->description("Elements that are being looped") ->attach_trigger ( boost::bind ( &CLoopOperation::config_elements, this ) ); m_options.add_option< OptionT<Uint> > ("LoopIndex", 0u) ->description("Index that is being looped") ->link_to( &m_idx ); }
LoopOperation::LoopOperation ( const std::string& name ) : common::Action(name), m_can_start_loop(true), m_call_config_elements(true), m_idx(0) { // Following option is ignored if the loop is not about elements options().add("elements", URI()) .supported_protocol(URI::Scheme::CPATH) .description("Elements that are being looped") .attach_trigger ( boost::bind ( &LoopOperation::config_elements, this ) ); options().add("loop_index", 0u) .description("Index that is being looped") .link_to( &m_idx ); }
InputSource* CatalogResolver::resolveEntity (const XMLCh* const publicId, const XMLCh* const systemId) { URI target; if( publicId && mCatalog.lookup( std::string(XMLString::transcode(publicId)), target) ) { target = mCatalog.lookup( target ); } else { if( systemId ) { mCatalog.lookup( URI(XMLString::transcode(systemId)), target ); } } return new URLInputSource( XMLURL(target.getText()) ); }