• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Uri类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Uri的典型用法代码示例。如果您正苦于以下问题:C++ Uri类的具体用法?C++ Uri怎么用?C++ Uri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Uri类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetDevice

  std::shared_ptr<CameraDriverInterface> GetDevice(const Uri& uri)
  {
    std::vector<Uri> suburis = splitUri(uri.url);
    std::vector<std::shared_ptr<CameraDriverInterface>> cameras;
    cameras.reserve(suburis.size());

    for( const Uri& uri : suburis ) {
      try {
        std::cout << "Creating stream from uri: " << uri.ToString()
                  << std::endl;
        cameras.emplace_back
            (DeviceRegistry<hal::CameraDriverInterface>::I().Create(uri));
      } catch ( std::exception& e ) {
        throw DeviceException(std::string("Error creating driver from uri \"") +
                              uri.ToString() + "\": " + e.what());
      }
    }

    if( cameras.empty() ) {
      throw DeviceException("No input cameras given to join");
    }

    JoinCameraDriver* pDriver = new JoinCameraDriver(cameras);
    return std::shared_ptr<CameraDriverInterface>( pDriver );
  }
开发者ID:HackLinux,项目名称:HAL,代码行数:25,代码来源:JoinCameraFactory.cpp


示例2: Uri_filenameTest

TESTFUNCTION void Uri_filenameTest() {
    String  fileName = "test.txt";
    Uri uri = Uri::fromAssets(fileName);

    jclogf("path = %s", uri.getPath().c_str());
    _assertTrue( strcmp( uri.getPath().c_str(), fileName.c_str() ) == 0);
}
开发者ID:SlayInk,项目名称:jointcoding,代码行数:7,代码来源:UriTest.cpp


示例3: match

bool RegexPattern::
match(Uri const& target, bool const caseSensitive/*= false*/) const
{
    if (m_disabled) return false;

    try {
        if (!m_regEx || caseSensitive != m_regExCaseSensitivity) {

            auto syntax = std::regex::ECMAScript;
            if (!caseSensitive) {
                syntax |= std::regex::icase;
            }

            m_regEx = std::make_unique<std::regex>(
                m_pattern.begin(), m_pattern.end(),
                syntax
            );

            m_regExCaseSensitivity = caseSensitive;
        }
        return std::regex_match(target.begin(), target.end(), *m_regEx);
    }
    catch (std::exception const& e) {
        std::cerr << "regex error: " << m_pattern << ":" << e.what() << "\n";
        m_disabled = true;
        return false;
    }
}
开发者ID:stream009,项目名称:libadblock,代码行数:28,代码来源:regex_pattern.cpp


示例4: open

ProtocolHandler::ErrorCode BuiltinProtocolHandlersLocal::open(const Uri &uri, iint32 openMode)
{
    if (!d->m_opened.empty() && d->m_opened.isValid()) {
        IDEAL_DEBUG_WARNING("the uri " << d->m_opened.uri() << " was opened. Closing");
        close();
    }
    d->m_opened = uri;
    if (!uri.isValid()) {
        return InvalidURI;
    }
    iint32 oflag = 0;
    if ((openMode & Read) && (openMode & Write)) {
        oflag = O_RDWR;
    } else if (openMode & Read) {
        oflag = O_RDONLY;
    } else {
        oflag = O_WRONLY;
    }
    d->m_fd = ::open(uri.path().data(), oflag);
    if (d->m_fd > -1) {
        return NoError;
    }
    switch (errno) {
        case EACCES:
            return InsufficientPermissions;
            break;
        default:
            return UnknownError;
            break;
    }
}
开发者ID:ereslibre,项目名称:ideallibrary-old,代码行数:31,代码来源:local_p.cpp


示例5: strTok

void
GeoLocation::Run(const String& command) {
	if(!command.IsEmpty()) {
		Uri commandUri;
		commandUri.SetUri(command);
		String method = commandUri.GetHost();
		StringTokenizer strTok(commandUri.GetPath(), L"/");
		if(strTok.GetTokenCount() > 1) {
			strTok.GetNextToken(callbackId);
			AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer());
		}
		AppLogDebug("Method %S, Callback: %S", method.GetPointer(), callbackId.GetPointer());
		// used to determine callback ID
		if(method == L"com.phonegap.Geolocation.watchPosition" && !callbackId.IsEmpty() && !IsWatching()) {
			AppLogDebug("watching position...");
			StartWatching();
		}
		if(method == L"com.phonegap.Geolocation.stop" && IsWatching()) {
			AppLogDebug("stop watching position...");
			StopWatching();
		}
		if(method == L"com.phonegap.Geolocation.getCurrentPosition" && !callbackId.IsEmpty() && !IsWatching()) {
			AppLogDebug("getting current position...");
			GetLastKnownLocation();
		}
		AppLogDebug("GeoLocation command %S completed", command.GetPointer());
	}
}
开发者ID:OldFrank,项目名称:phonegap,代码行数:28,代码来源:GeoLocation.cpp


示例6: strTok

void
Accelerometer::Run(const String& command) {
	if (!command.IsEmpty()) {
		Uri commandUri;
		commandUri.SetUri(command);
		String method = commandUri.GetHost();
		StringTokenizer strTok(commandUri.GetPath(), L"/");
		if(strTok.GetTokenCount() == 1) {
			strTok.GetNextToken(callbackId);
			AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer());
		}
		if(method == L"com.cordova.Accelerometer.watchAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			StartSensor();
		}
		if(method == L"com.cordova.Accelerometer.clearWatch" && IsStarted()) {
			StopSensor();
		}
		if(method == L"com.cordova.Accelerometer.getCurrentAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			GetLastAcceleration();
		}
		AppLogDebug("Acceleration command %S completed", command.GetPointer());
	} else {
		AppLogDebug("Can't run empty command");
	}
}
开发者ID:Emadello,项目名称:phonegap,代码行数:25,代码来源:Accelerometer.cpp


示例7: switch

bool BuiltinProtocolHandlersHttp::Private::sendCommand(CommandType commandType, const Uri &uri)
{
    iint32 commandSize = 0;
    switch (commandType) {
        case Get:
            commandSize = strlen(m_commandGet);
            break;
        case Head:
            commandSize = strlen(m_commandHead);
            break;
    }
    commandSize += uri.host().size() + uri.path().size();
    ichar *command = (ichar*) calloc(commandSize + 1, sizeof(ichar));
    switch (commandType) {
        case Get:
            sprintf(command, "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", uri.path().data(), uri.host().data());
            break;
        case Head:
            sprintf(command, "HEAD %s HTTP/1.1\r\nHost: %s\r\n\r\n", uri.path().data(), uri.host().data());
            break;
        default:
            IDEAL_DEBUG_WARNING("unknown command type");
            break;
    }
    const iint32 bytesSent = send(m_sockfd, command, commandSize, 0);
    free(command);
    return bytesSent == commandSize;
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例8: parseUrl

bool HttpParserImpl::parseUrl()
{
    Uri uri;
    if(!uri.parse(url_)) {
        return false;
    }
    const std::string& query = uri.getQuery();
    std::string::size_type pos = 0;
    while (true) {
        auto pos1 = query.find('=', pos);
        if(pos1 == std::string::npos){
            break;
        }
        std::string name(query.begin()+pos, query.begin()+pos1);
        pos = pos1 + 1;
        pos1 = query.find('&', pos);
        if(pos1 == std::string::npos){
            std::string value(query.begin()+pos, query.end());
            addParamValue(name, value);
            break;
        }
        std::string value(query.begin()+pos, query.begin()+pos1);
        pos = pos1 + 1;
        addParamValue(name, value);
    }
    
    return true;
}
开发者ID:jimmy486,项目名称:kuma,代码行数:28,代码来源:HttpParserImpl.cpp


示例9:

void
DebugConsole::CleanUp(String& str) {
	Uri uri;
	uri.SetUri(str);
	str.Clear();
	str.Append(uri.ToString());
}
开发者ID:4z3,项目名称:phonegap,代码行数:7,代码来源:DebugConsole.cpp


示例10: writeBuffer

void InvocationUpnp::WriteRequest(const Uri& aUri)
{
    Sws<1024> writeBuffer(iSocket);
    WriterHttpRequest writerRequest(writeBuffer);
    Bwh body;

    try {
        Endpoint endpoint(aUri.Port(), aUri.Host());
        TUint timeout = iCpStack.Env().InitParams()->TcpConnectTimeoutMs();
        iSocket.Connect(endpoint, timeout);
    }
    catch (NetworkTimeout&) {
        iInvocation.SetError(Error::eSocket, Error::eCodeTimeout, Error::kDescriptionSocketTimeout);
        THROW(NetworkTimeout);
    }

    try {
        InvocationBodyWriter::Write(iInvocation, body);
        WriteHeaders(writerRequest, aUri, body.Bytes());
        writeBuffer.Write(body);
        writeBuffer.WriteFlush();
    }
    catch (WriterError) {
        iInvocation.SetError(Error::eHttp, Error::kCodeUnknown, Error::kDescriptionUnknown);
        THROW(WriterError);
    }
}
开发者ID:fuzzy01,项目名称:ohNet,代码行数:27,代码来源:ProtocolUpnp.cpp


示例11: kRequestMethod

void EventUpnp::SubscribeWriteRequest(const Uri& aPublisher, const Uri& aSubscriber, TUint aDurationSecs)
{
    const Brn kRequestMethod("SUBSCRIBE");
    const Brn kMethodCallback("CALLBACK");
    const Brn kMethodNt("NT");
    const Brn kFieldNt("upnp:event");
    Sws<1024> writeBuffer(iSocket);
    WriterHttpRequest writerRequest(writeBuffer);

    writerRequest.WriteMethod(kRequestMethod, aPublisher.PathAndQuery(), Http::eHttp11);
    Http::WriteHeaderHostAndPort(writerRequest, aPublisher);

    IWriterAscii& writerField = writerRequest.WriteHeaderField(kMethodCallback);
    writerField.Write('<');
    writerField.Write(aSubscriber.AbsoluteUri());
    writerField.Write('>');
    writerField.WriteNewline();

    writerField = writerRequest.WriteHeaderField(kMethodNt);
    writerField.Write(kFieldNt);
    writerField.WriteNewline();

    WriteHeaderTimeout(writerRequest, aDurationSecs);

    writerField.WriteNewline();
    writerRequest.WriteFlush();
}
开发者ID:fuzzy01,项目名称:ohNet,代码行数:27,代码来源:ProtocolUpnp.cpp


示例12: single

TBool CpiDeviceListUpnp::IsLocationReachable(const Brx& aLocation) const
{
    /* linux's filtering of multicast messages appears to be buggy and messages
       received by all interfaces are sometimes delivered to sockets which are
       bound to / members of a group on a single (different) interface.  It'd be
       more correct to filter these out in SsdpListenerMulticast but that would
       require API changes which would be more inconvenient than just moving the
       filtering here.
       This should be reconsidered if we ever add more clients of SsdpListenerMulticast */
    TBool reachable = false;
    Uri uri;
    try {
        uri.Replace(aLocation);
    }
    catch (UriError&) {
        return false;
    }
    iLock.Wait();
    Endpoint endpt(0, uri.Host());
    NetworkAdapter* nif = iCpStack.Env().NetworkAdapterList().CurrentAdapter("CpiDeviceListUpnp::IsLocationReachable");
    if (nif != NULL) {
        if (nif->Address() == iInterface && nif->ContainsAddress(endpt.Address())) {
            reachable = true;
        }
        nif->RemoveRef("CpiDeviceListUpnp::IsLocationReachable");
    }
    iLock.Signal();
    return reachable;
}
开发者ID:DoomHammer,项目名称:ohNet,代码行数:29,代码来源:CpiDeviceUpnp.cpp


示例13: delim

void
Network::Run(const String& command) {
	if (!command.IsEmpty()) {
		String args;
		String delim(L"/");
		command.SubString(String(L"gap://").GetLength(), args);
		StringTokenizer strTok(args, delim);
		if(strTok.GetTokenCount() < 3) {
			AppLogDebug("Not enough params");
			return;
		}
		String method;
		String hostAddr;
		strTok.GetNextToken(method);
		strTok.GetNextToken(callbackId);
		strTok.GetNextToken(hostAddr);

		// URL decoding
		Uri uri;
		uri.SetUri(hostAddr);
		AppLogDebug("Method %S, callbackId %S, hostAddr %S URI %S", method.GetPointer(), callbackId.GetPointer(), hostAddr.GetPointer(), uri.ToString().GetPointer());
		if(method == L"org.apache.cordova.Network.isReachable") {
			IsReachable(uri.ToString());
		}
		AppLogDebug("Network command %S completed", command.GetPointer());
		} else {
			AppLogDebug("Can't run empty command");
		}
}
开发者ID:AjayTShephertz,项目名称:phonegap,代码行数:29,代码来源:Network.cpp


示例14: Abort

void
BitmapImage::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
	if (args->GetProperty ()->GetOwnerType () != Type::BITMAPIMAGE) {
		BitmapSource::OnPropertyChanged (args, error);
		return;
	}

	if (args->GetId () == BitmapImage::UriSourceProperty) {
		Uri *uri = args->GetNewValue () ? args->GetNewValue ()->AsUri () : NULL;

		Abort ();

		if (Uri::IsNullOrEmpty (uri)) {
			SetBitmapData (NULL, false);
		} else if (uri->IsInvalidPath ()) {
			if (IsBeingParsed ())
				MoonError::FillIn (error, MoonError::ARGUMENT_OUT_OF_RANGE, 0, "invalid path found in uri");
			SetBitmapData (NULL, false);
		} else {
			AddTickCall (uri_source_changed_callback);
		}
	} else if (args->GetId () == BitmapImage::ProgressProperty) {
		if (HasHandlers (DownloadProgressEvent))
			Emit (DownloadProgressEvent, new DownloadProgressEventArgs (GetProgress ()));
	}

	NotifyListenersOfPropertyChange (args, error);
}
开发者ID:lewing,项目名称:moon,代码行数:29,代码来源:bitmapimage.cpp


示例15: WriteHeaderHostAndPort

void Http::WriteHeaderHostAndPort(WriterHttpHeader& aWriter, const Uri& aUri)
{
    IWriterAscii& writer = aWriter.WriteHeaderField(Http::kHeaderHost);
    writer.Write(aUri.Host());
    writer.Write(':');
    writer.WriteUint(aUri.Port());
    writer.WriteNewline();
}
开发者ID:astaykov,项目名称:ohNet,代码行数:8,代码来源:Http.cpp


示例16: getUri

//==============================================================================
std::string Uri::getUri(const std::string& _input)
{
  Uri uri;
  if(uri.fromStringOrPath(_input))
    return uri.toString();
  else
    return "";
}
开发者ID:jpgr87,项目名称:dart,代码行数:9,代码来源:Uri.cpp


示例17: get_scheme

//=============================================================================
bool Uri::operator!=(const Uri& v) const
{
  return get_scheme() != v.get_scheme() ||
    get_host() != v.get_host() ||
    get_port() != v.get_port() ||
    get_path() != v.get_path() ||
    get_query() != v.get_query();
}
开发者ID:sconemad,项目名称:sconeserver,代码行数:9,代码来源:Uri.cpp


示例18: operator

 void operator()(Uri &uri) const {
   uri.append(scheme);
   if (opaque_schemes::exists(scheme)) {
     uri.append(":");
   } else {
     uri.append("://");
   }
 }
开发者ID:Coldrain,项目名称:cpp-netlib,代码行数:8,代码来源:scheme.hpp


示例19: Compare

Int32 Uri::Compare(const Uri& Uri1, const Uri& Uri2,
                   const UriComponents::Type PartToCompare,
                   const UriFormat::Type CompareFormat)
{
    String a=Uri1.GetComponents(PartToCompare,CompareFormat);
    String b=Uri2.GetComponents(PartToCompare,CompareFormat);
    return a.Compare(b);
}
开发者ID:wangscript,项目名称:RadonFramework,代码行数:8,代码来源:Uri.cpp


示例20: TCPSocket

 void Client::request(
     Method method, Uri uri,
     Header header,
     void *data, int len){
     
     TCPSocket *socket = new TCPSocket(
         uri.getDomain().c_str(), uri.getPort(),
         [=](int err, TCPSocket *socket){
             if( err != eNoError ){
                 EP_SAFE_DEFER( responseCallback, err, Header(),"" );
             }
             else{
                 string *buffer = new string();
                 
                 socket->onReceive(
                     [=](void *data, int len){
                         buffer->append( (char*)data );
                     });
                 socket->onUnbind(
                     [=](){
                         Header header;
                         string body;
                         int offset = header.load( *buffer );
                         
                         /*
                          todo : parse chunked content-length
                          */
                         header.getField(
                             "Transfer-Encoding");
                         
                         if( offset == - 1 ){
                             EP_SAFE_DEFER( responseCallback, eParseError, Header(),"" );
                         }
                         else{
                             body = buffer->substr( offset );
                             
                             EP_SAFE_DEFER( responseCallback, eNoError, header, body );
                         }
                         
                         delete buffer;
                     });
                 
                 string requestLine =
                     generateRequestLine( method, uri.getRequestUri(), "HTTP/1.1" );
                 string headerString =
                     header.dump();
                 
                 socket->write(
                     (void*)requestLine.c_str(), requestLine.size());
                 socket->write(
                     (void*)headerString.c_str(), headerString.size());
                 
                 if( len > 0 ){
                     socket->write( data, len );
                 }
             }
         });
 }
开发者ID:pjc0247,项目名称:EventPie,代码行数:58,代码来源:Client.cpp



注:本文中的Uri类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Url类代码示例发布时间:2022-05-31
下一篇:
C++ UpperTriangularMatrix类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap