本文整理汇总了C++中resolver函数的典型用法代码示例。如果您正苦于以下问题:C++ resolver函数的具体用法?C++ resolver怎么用?C++ resolver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolver函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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异常:[未知异常]");
}
}
示例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;
}
示例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");
}
示例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());
}
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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_;
}