本文整理汇总了C++中resolver函数的典型用法代码示例。如果您正苦于以下问题:C++ resolver函数的具体用法?C++ resolver怎么用?C++ resolver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolver函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: document
bool XPathValidator::checkAgainstDTD(QString const &query) const
{
// If we cannot parse the query and traverse its AST without an exception, something
// must be wrong with the query...
try {
QStringList subQueries = query.split("+|+");
// Create an emptry document and associate namespace resolvers with it.
AutoDelete<xercesc::DOMDocument> document(
xercesc::DOMImplementation::getImplementation()->createDocument());
AutoDelete<xercesc::DOMXPathNSResolver> resolver(
document->createNSResolver(document->getDocumentElement()));
resolver->addNamespaceBinding(X("fn"),
X("http://www.w3.org/2005/xpath-functions"));
resolver->addNamespaceBinding(X("xs"),
X("http://www.w3.org/2001/XMLSchema"));
foreach(QString subQuery, subQueries)
{
DynamicContext *ctx(s_xqilla.createContext(XQilla::XPATH2));
ctx->setXPath1CompatibilityMode(true);
ctx->setNSResolver(resolver);
AutoDelete<XQQuery> xqQuery(s_xqilla.parse(X(subQuery.toUtf8().constData()), ctx));
ASTNode *root = xqQuery->getQueryBody();
// std::cout << xqQuery->getQueryPlan() << std::endl;
QSharedPointer<QueryScope> rootScope(new QueryScope());
rootScope->setNodeName("[document root]");
if (!inspect(root, rootScope, *d_dtd))
return false;
}
return true;
} catch (XQException &e) {
开发者ID:rug-compling,项目名称:dact,代码行数:40,代码来源:XPathValidator.cpp
示例2: main
int main(int argc, char* argv[]) {
try {
if (argc != 3) {
std::cerr << "Usage: irc_client <host> <port>\n";
return 1;
}
boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::query query(argv[1], argv[2]);
tcp::resolver::iterator iterator = resolver.resolve(query);
IRCClient c(io_service, iterator);
io_service.run();
c.close();
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << "\n";
}
return 0;
}
开发者ID:sheik,项目名称:VarysCPP,代码行数:22,代码来源:main.cpp
示例3: LOG
bool SharedLibrary::Relocate(LibraryList* lib_list,
Vector<LibraryView*>* dependencies,
Error* error) {
// Apply relocations.
LOG("%s: Applying relocations to %s\n", __FUNCTION__, base_name_);
ElfRelocations relocations;
if (!relocations.Init(&view_, error))
return false;
#if defined(__arm__) || defined(__aarch64__)
relocations.RegisterPackedRelocations(packed_relocations_);
#endif
SharedLibraryResolver resolver(this, lib_list, dependencies);
if (!relocations.ApplyAll(&symbols_, &resolver, error))
return false;
LOG("%s: Relocations applied for %s\n", __FUNCTION__, base_name_);
return true;
}
开发者ID:7kbird,项目名称:chrome,代码行数:22,代码来源:crazy_linker_shared_library.cpp
示例4: main
int main() {
asio::io_service io_service;
// resolve hostname
asio::ip::tcp::resolver resolver(io_service);
resolver.async_resolve({ "api.ipify.org", "80" }, [&](const auto& error, auto iterator) {
if (error) {
std::cout << error.message() << std::endl;
return;
}
// connect to host
auto socket = std::make_shared<asio::ip::tcp::socket>(io_service);
asio::async_connect(*socket, iterator, [socket](const auto& error, auto) {
if (error) {
std::cout << error.message() << std::endl;
return;
}
// send request
asio::async_write(*socket, asio::buffer(
"GET /?format=json HTTP/1.1\r\n"
"Host: api.ipify.org\r\n"
"Connection: close\r\n\r\n"), [socket](const auto& error, auto) {
if (error) {
std::cout << error.message() << std::endl;
return;
}
// receive response, read until connection closed
auto buffer = std::make_shared<std::array<char, 1024>>();
asio::async_read(*socket, asio::buffer(buffer->data(), buffer->size()),
[socket, buffer](const auto&, auto size) {
std::cout << std::string(buffer->data(), size) << std::endl;
});
});
});
});
io_service.run();
return 0;
}
开发者ID:ecdhe,项目名称:various_language_examples,代码行数:39,代码来源:c++14_asio.cpp
示例5: error
bool
SocketOutput::connect_to_server (const std::string &name)
{
std::map<std::string, std::string> rest_args;
std::string baseurl;
rest_args["port"] = socket_pvt::default_port;
rest_args["host"] = socket_pvt::default_host;
if (! Strutil::get_rest_arguments (name, baseurl, rest_args)) {
error ("Invalid 'open ()' argument: %s", name.c_str ());
return false;
}
try {
ip::tcp::resolver resolver (io);
ip::tcp::resolver::query query (rest_args["host"].c_str (),
rest_args["port"].c_str ());
ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
ip::tcp::resolver::iterator end;
boost::system::error_code err = error::host_not_found;
while (err && endpoint_iterator != end) {
socket.close ();
socket.connect (*endpoint_iterator++, err);
}
if (err) {
error ("Host \"%s\" not found", rest_args["host"].c_str ());
return false;
}
} catch (boost::system::system_error &err) {
error ("Error while connecting: %s", err.what ());
return false;
} catch (...) {
error ("Error while connecting: unknown exception");
return false;
}
return true;
}
开发者ID:brianhall77,项目名称:oiio,代码行数:39,代码来源:socketoutput.cpp
示例6: init_connection_handler
void server_base::init(init_connectionhandler_func init_connection_handler, accept_handler_func accept_handler) {
init_connection_handler();
if (!new_connection_) {
throw std::invalid_argument("cannot initialize a server without a valid connection");
}
// Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
boost::asio::ip::tcp::resolver resolver(io_service_);
boost::asio::ip::tcp::resolver::query query(settings_.listening_address, settings_.listening_port);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
acceptor_.open(endpoint.protocol());
acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
// bind to our port
acceptor_.bind(endpoint);
// listen for incoming requests
acceptor_.listen();
// start the accept thread
acceptor_.async_accept(new_connection_->socket(), accept_handler);
}
开发者ID:Digitaldna59,项目名称:domoticz,代码行数:22,代码来源:server.cpp
示例7: LOG4CXX_ERROR
void client_socket_utils::session_connect(socket_session_ptr pSession)
{
std::string& addr = pSession->get_remote_addr();
try
{
//注册关闭回调函数
pSession->installCloseCallBack(boost::bind(&client_socket_utils::close_callback, this, _1));
//注册读到数据回调函数
pSession->installReadDataCallBack(boost::bind(&client_socket_utils::read_data_callback, this, _1, _2, _3));
std::vector<std::string> ip_port;
boost::split(ip_port, addr, boost::is_any_of(":"));
if (ip_port.size() < 2)
{
//throw std::runtime_error("ip 格式不正确!");
LOG4CXX_ERROR(firebird_log, "[" << addr << "] ip 格式不正确!");
return;
}
tcp::resolver resolver(pSession->socket().get_io_service());
tcp::resolver::query query(ip_port[0], ip_port[1]);
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
//pSession->set_begin_endpoint(endpoint_iterator);//设置起始地址,以便重连
//由于客户端是不断重连的,即使还未连接也要保存该session
m_manager.add_session(pSession);
tcp::endpoint endpoint = *endpoint_iterator;
pSession->socket().async_connect(endpoint,
boost::bind(&client_socket_utils::handle_connect, this, boost::asio::placeholders::error, ++endpoint_iterator, pSession));
} catch (std::exception& e)
{
LOG4CXX_ERROR(firebird_log, KDS_CODE_INFO << "连接远程地址:[" << addr << "],socket异常:[" << e.what() << "]");
} catch (...)
{
LOG4CXX_ERROR(firebird_log, KDS_CODE_INFO << "连接远程地址:[" << addr << "],socket异常:[未知异常]");
}
}
开发者ID:piaoyimq,项目名称:CppSpace,代码行数:39,代码来源:client_socket_utils.cpp
示例8: ping
bool ping(const char* hostname)
{
// Prepare and resolve the host name
boost::asio::ip::icmp::resolver::query query(boost::asio::ip::icmp::v4(), hostname, "");
boost::asio::ip::icmp::resolver resolver(io_service);
boost::system::error_code ec;
boost::asio::ip::icmp::endpoint destination = resolver.resolve(query, ec)->endpoint();
if (ec)
return false;
// Prepare the ICMP packet
const int length = 256;
char data[length];
memset(data, 0xff, length);
// Send the ICMP packet
boost::asio::ip::icmp::socket socket(io_service, boost::asio::ip::icmp::v4());
socket.send_to(boost::asio::buffer(data, length), destination);
// Wait for a reply
return true;
}
开发者ID:perezdidac,项目名称:lourdes,代码行数:22,代码来源:ping.cpp
示例9: init
void init(const boost::property_tree::ptree& pt) throw(std::runtime_error) {
if (m_acceptor.is_open())
m_acceptor.close();
std::string url = pt.get<std::string>("address", "tcp://0.0.0.0:0");
std::string proto, addr, port, path;
if (!parse_url(url, proto, addr, port, path))
THROW_RUNTIME_ERROR("Invalid URL address: " << url);
if (proto != "tcp")
THROW_RUNTIME_ERROR("Expected 'tcp' protocol type!");
if (port.empty() || port == "0")
THROW_RUNTIME_ERROR("tcp_server invalid 'port' configuration: " << port);
// Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
boost::asio::ip::tcp::resolver resolver(this->m_io_service);
boost::asio::ip::tcp::resolver::query query(addr, port);
boost::asio::ip::tcp::endpoint end;
m_endpoint = *resolver.resolve(query);
if (m_endpoint == end)
THROW_RUNTIME_ERROR("Error resolving address");
}
开发者ID:erlanger,项目名称:eixx,代码行数:22,代码来源:server.hpp
示例10: io_service
ClientConnection::ClientConnection( boost::asio::io_service& io_service, std::string address, int port )
: io_service( io_service )
{
LOGTRACE(LT("Creating ClientConnection to "), address, LT(":"), port);
// connect the socket to the requested endpoint
boost::asio::ip::tcp::resolver resolver( io_service );
boost::asio::ip::tcp::resolver::query query( address, std::to_string( port ) );
boost::system::error_code ec;
boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve( query, ec );
if (ec)
LOGERROR(LT("Failed to resolve endpoint "), address, LT(":"), port, LT(" - "), ec.message());
try
{
this->socket = std::unique_ptr< boost::asio::ip::tcp::socket >(new boost::asio::ip::tcp::socket(io_service));
boost::asio::ip::tcp::resolver::iterator connected_endpoint = boost::asio::connect(*this->socket, endpoint_iterator);
LOGFINE(LT("Connected - "), connected_endpoint->service_name(), LT(" - "), connected_endpoint->host_name());
}
catch (boost::system::system_error e)
{
LOGERROR(LT("Failed to connect to "), address, LT(":"), port, LT(" - "), e.code().message());
}
}
开发者ID:abhay447,项目名称:malmo,代码行数:22,代码来源:ClientConnection.cpp
示例11: resolver
ssl::stream<tcp::socket> *NetworkConnector::connect(const std::string &address, unsigned int default_port,
ssl::context *ctx, boost::system::error_code &ec)
{
std::string str_ip = address;
std::string str_port = str_ip.substr(str_ip.find(':', 0) + 1, std::string::npos);
str_ip = str_ip.substr(0, str_ip.find(':', 0));
tcp::resolver resolver(m_io_service);
tcp::resolver::query query(str_ip, str_port);
tcp::resolver::iterator it = resolver.resolve(query);
ssl::stream<tcp::socket> *socket = new ssl::stream<tcp::socket>(m_io_service, *ctx);
socket->next_layer().connect(*it, ec);
if(ec.value() != 0)
{
delete socket;
return nullptr;
}
return socket;
}
开发者ID:robert1111,项目名称:Astron,代码行数:22,代码来源:NetworkConnector.cpp
示例12: thread_pool_size_
server::server(const std::string& address, const std::string& port,
std::size_t thread_pool_size)
: thread_pool_size_(thread_pool_size),
acceptor_(io_service_),
new_connection_(new connection(io_service_, request_handler_)),
request_handler_()
{
// Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
boost::asio::ip::tcp::resolver resolver(io_service_);
boost::asio::ip::tcp::resolver::query query(address, port);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
acceptor_.open(endpoint.protocol());
acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
acceptor_.bind(endpoint);
acceptor_.listen();
acceptor_.async_accept(new_connection_->socket(),
boost::bind(&server::handle_accept, this,
boost::asio::placeholders::error));
// plog::instance()->set_file("http_proxy.exe.log");
// plog::instance()->set_output_type(postman::OUT_FILE);
}
开发者ID:BackupTheBerlios,项目名称:roxy-svn,代码行数:22,代码来源:server.cpp
示例13: resolver
void CommandServer::createTcpEndpoint()
{
std::stringstream streamForPort;
streamForPort << m_options.port;
Ip::tcp::resolver resolver(m_tcpAcceptor.get_io_service());
// TODO: support ipv6
Ip::tcp::resolver::query query(Ip::tcp::v4(),
m_options.host,
streamForPort.str(),
Ip::resolver_query_base::numeric_service);
Ip::tcp::endpoint endpoint = *resolver.resolve(query);
m_tcpAcceptor.open(endpoint.protocol());
m_tcpAcceptor.set_option(Ip::tcp::acceptor::reuse_address(true));
m_tcpAcceptor.bind(endpoint);
m_tcpAcceptor.listen();
LOG(info) << "Listening on " << endpoint;
startAcceptOnTcp();
}
开发者ID:boostcache,项目名称:boostcache,代码行数:22,代码来源:commandserver.cpp
示例14: adoptPtr
void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, const bool* reportProgress)
{
v8::HeapProfiler* profiler = m_isolate->GetHeapProfiler();
if (!profiler) {
*errorString = "Cannot access v8 heap profiler";
return;
}
OwnPtr<HeapSnapshotProgress> progress;
if (asBool(reportProgress))
progress = adoptPtr(new HeapSnapshotProgress(frontend()));
v8::HandleScope handleScope(m_isolate); // Remove?
GlobalObjectNameResolver resolver(m_isolate);
const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(progress.get(), &resolver);
if (!snapshot) {
*errorString = "Failed to take heap snapshot";
return;
}
HeapSnapshotOutputStream stream(frontend());
snapshot->Serialize(&stream);
const_cast<v8::HeapSnapshot*>(snapshot)->Delete();
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:22,代码来源:InspectorHeapProfilerAgent.cpp
示例15: resolver
int Resolver::resolve(Compiler& compiler, Module& module, Resolver* parent,
ResolvedProcedure* procedure, bool isModuleBody,
gc<Pattern> leftParam, gc<Pattern> rightParam,
gc<Pattern> valueParam, gc<Expr> body)
{
Resolver resolver(compiler, module, parent, isModuleBody);
// Create a scope for the body.
Scope scope(&resolver);
resolver.scope_ = &scope;
// First, we allocate slots for the destructured parameters. We do this
// first so that all parameter slots for the method are contiguous at the
// beginning of the method's slot window. The caller will assume this when
// it sets up the arguments before the call.
resolver.allocateSlotsForParam(leftParam);
resolver.allocateSlotsForParam(rightParam);
resolver.allocateSlotsForParam(valueParam);
// Create a slot for the result value.
resolver.makeLocal(new SourcePos(NULL, 0, 0, 0, 0),
String::create("(result)"));
// Now that we've got our slots set up, we can actually resolve the nested
// patterns for the param (if there are any).
resolver.destructureParam(leftParam);
resolver.destructureParam(rightParam);
resolver.destructureParam(valueParam);
resolver.resolve(body);
scope.end();
// TODO(bob): Copying this stuff here is lame.
procedure->resolve(resolver.maxLocals_, resolver.closures_);
return resolver.maxLocals_;
}
开发者ID:relrod,项目名称:magpie,代码行数:38,代码来源:Resolver.cpp
示例16: main
int main(int argc, char* argv[])
{
try
{
if (argc != 2)
{
std::cerr << "Usage: daytime_client <host>" << std::endl;
return 1;
}
boost::asio::io_service io_service;
// Set the name of the file that all logger instances will use.
services::logger logger(io_service, "");
logger.use_file("log.txt");
// Resolve the address corresponding to the given host.
boost::asio::ip::tcp::resolver resolver(io_service);
boost::asio::ip::tcp::resolver::query query(argv[1], "daytime");
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
boost::asio::ip::tcp::endpoint endpoint = *iterator;
// Start an asynchronous connect.
debug_stream_socket socket(io_service);
socket.async_connect(endpoint,
boost::bind(connect_handler,
boost::asio::placeholders::error, &socket, ++iterator));
// Run the io_service until all operations have finished.
io_service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
}
return 0;
}
开发者ID:fcrick,项目名称:RepSnapper,代码行数:38,代码来源:daytime_client.cpp
示例17: resolver
boost::asio::ip::tcp::resolver::iterator ApnsService::resolver_addr(bool feedback)
{
std::string addr;
std::string port;
if (!feedback)
{
addr.assign(HOST_PRODUCTION_ENV);
port.assign(PORT_PRODUCTION_ENV);
if (apns_params_.Developer)
{
addr.assign(HOST_DEVELOPMENT_ENV);
port.assign(PORT_DEVELOPMENT_ENV);
}
}
else
{
addr.assign(FEEDBACK_HOST_PRODUCTION_ENV);
port.assign(FEEDBACK_PORT_PRODUCTION_ENV);
if (apns_params_.Developer)
{
addr.assign(FEEDBACK_HOST_DEVELOPMENT_ENV);
port.assign(FEEDBACK_PORT_DEVELOPMENT_ENV);
}
}
boost::asio::ip::tcp::resolver resolver(*io_service_);
boost::asio::ip::tcp::resolver::query query(addr, port);
boost::asio::ip::tcp::resolver::iterator iterator = boost::asio::ip::tcp::resolver::iterator();
try
{
iterator = resolver.resolve(query);
}
catch (const boost::system::system_error& err)
{
LOGFMTE("resolver error:%s", err.what());
}
return iterator;
}
开发者ID:ylywyn,项目名称:apns-cpp,代码行数:38,代码来源:ApnsService.cpp
示例18: resolve
//using namespace udp;
asio::ip::udp::endpoint resolve(const asio::ip::udp::resolver::query &q) {
asio::ip::udp::endpoint ep;
fibers::detail::fiber_ptr_t this_fiber(fibers::detail::fiber_object::current_fiber_->shared_from_this());
asio::ip::udp::resolver resolver(this_fiber->io_service_);
CHECK_CALLER(this_fiber);
if (this_fiber->caller_) {
(*(this_fiber->caller_))([this_fiber, &q, &ep, &resolver](){
this_fiber->state_=fibers::detail::fiber_object::BLOCKED;
resolver.async_resolve(q, (this_fiber->fiber_strand_.wrap([this_fiber, &ep](const std::error_code &ec, asio::ip::udp::resolver::iterator iterator){
this_fiber->last_error_=ec;
if (!ec) {
ep=*iterator;
}
this_fiber->state_=fibers::detail::fiber_object::RUNNING;
this_fiber->one_step();
})));
});
} else {
// TODO: Error
}
this_fiber->throw_on_error();
return ep;
}
开发者ID:zylthinking,项目名称:fibio,代码行数:24,代码来源:udp.cpp
示例19: start
void start(const std::string & ip_addr, const std::string & port)
{
ip::tcp::resolver resolver(io_service_pool_.get_now_io_service());
ip::tcp::resolver::query query(ip_addr, port);
ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
boost::system::error_code ec;
acceptor_.open(endpoint.protocol(), ec);
if (ec) {
// Open endpoint error
std::cout << "async_asio_echo_serv_ex::start() - Error: (code = " << ec.value() << ") "
<< ec.message().c_str() << std::endl;
return;
}
boost::asio::socket_base::reuse_address option(true);
acceptor_.set_option(option);
acceptor_.bind(endpoint);
acceptor_.listen();
do_accept();
}
开发者ID:shines77,项目名称:netlib_test,代码行数:23,代码来源:async_aiso_echo_serv_ex.hpp
示例20: builder
// analayze semantic information...
// In current implement, analayze phase is separated to 2 steps.
// One is building phase which create scoep tree.
// And the other one is resolving phase.
// DCC syntax not need multi step analayzer,
// but I implement it because for future improvement,
// and for studying how to implement multi phase analyzer.
dcc::semantic::scope::symbol_table semantic_analayzer::analyze(dcc::ast::module &mod){
// create symbol table
auto root = std::make_shared<dcc::semantic::scope::global_scope>();
scope_builder builder(root);
dcc::ast::helper::traverse(builder, mod);
if(builder.error_counts() > 0){
builder.dump_errors();
// throw exception
throw semantic_exception();
}
// resolve symbol
symbol_resolver resolver(root);
dcc::ast::helper::traverse(resolver, mod);
if(resolver.error_counts() > 0){
resolver.dump_errors();
// throw exception
throw semantic_exception();
}
return dcc::semantic::scope::symbol_table(root);
}
开发者ID:Kmotiko,项目名称:LittleBetterDCC,代码行数:30,代码来源:semantic_analyzer.cpp
注:本文中的resolver函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论