当前位置: 首页>>代码示例>>C++>>正文


C++ URI::setScheme方法代码示例

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


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

示例1: getTargetSources

brion::URIs BlueConfig::getTargetSources() const
{
    const std::string& run = _impl->getRun();

    URIs uris;
    const std::string& nrnPath =
        get(brion::CONFIGSECTION_RUN, run, BLUECONFIG_NRN_PATH_KEY);
    if (!nrnPath.empty())
    {
        URI uri;
        uri.setScheme("file");
        uri.setPath(nrnPath + "/" + CIRCUIT_TARGET_FILE);
        uris.push_back(uri);
    }

    const std::string& targetPath =
        get(brion::CONFIGSECTION_RUN, run, BLUECONFIG_TARGET_FILE_KEY);
    if (!targetPath.empty())
    {
        URI uri;
        uri.setScheme("file");
        uri.setPath(targetPath);
        uris.push_back(uri);
    }

    return uris;
}
开发者ID:tribal-tec,项目名称:Brion,代码行数:27,代码来源:blueConfig.cpp

示例2: testDownload

void FTPStreamFactoryTest::testDownload()
{
	FTPStreamFactory::setPasswordProvider(0);

	DialogServer server;
	server.addResponse("220 localhost FTP ready");
	server.addResponse("331 Password required");
	server.addResponse("230 Welcome");
	server.addResponse("200 Type set to I");
	server.addResponse("200 Type set to A");

	DialogServer dataServer(false);
	dataServer.addResponse("line1\r\nline2");
	std::ostringstream epsv;
	epsv << "229 Entering Extended Passive Mode (|||" << dataServer.port() << "|)";
	server.addResponse(epsv.str());
	server.addResponse("150 sending data\r\n226 Transfer complete");
	server.addResponse("221 Good bye");

	URI uri;
	uri.setScheme("ftp");
	uri.setHost("localhost");
	uri.setPort(server.port());
	uri.setPath("/test.txt;type=a");
	FTPStreamFactory sf;
	std::auto_ptr<std::istream> pStr(sf.open(uri));

	std::ostringstream dataStr;
	StreamCopier::copyStream(*pStr.get(), dataStr);
	
	pStr.reset();
		
	std::string s(dataStr.str());
	assert (s == "line1\r\nline2\r\n");
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:35,代码来源:FTPStreamFactoryTest.cpp

示例3: testMissingPasswordProvider

void FTPStreamFactoryTest::testMissingPasswordProvider()
{
	FTPStreamFactory::setPasswordProvider(0);

	DialogServer server;
	server.addResponse("220 localhost FTP ready");
	server.addResponse("221 Good bye");

	URI uri;
	uri.setScheme("ftp");
	uri.setHost("localhost");
	uri.setPort(server.port());
	uri.setPath("/test.txt;type=a");
	uri.setUserInfo("user");

	try
	{
		FTPStreamFactory sf;
		std::auto_ptr<std::istream> pStr(sf.open(uri));
		fail("no password provider - must throw");
	}
	catch (FTPException&)
	{
	}
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:25,代码来源:FTPStreamFactoryTest.cpp

示例4: getMorphologyURI

 URI getMorphologyURI( const std::string& name ) const
 {
     URI uri;
     uri.setPath( _morphologySource.getPath() + "/" + name + ".h5" );
     uri.setScheme( "file" );
     return uri;
 }
开发者ID:jafyvilla,项目名称:Brion,代码行数:7,代码来源:circuit.cpp

示例5: getSynapseSource

URI BlueConfig::getSynapseSource() const
{
    URI uri;
    uri.setScheme("file");
    uri.setPath(
        get(CONFIGSECTION_RUN, _impl->getRun(), BLUECONFIG_NRN_PATH_KEY));
    return uri;
}
开发者ID:tribal-tec,项目名称:Brion,代码行数:8,代码来源:blueConfig.cpp

示例6: getSpikeSource

URI BlueConfig::getSpikeSource() const
{
    std::string path =
        get(CONFIGSECTION_RUN, _impl->getRun(), BLUECONFIG_SPIKES_PATH_KEY);
    if (path.empty())
        path = _impl->getOutputRoot() + SPIKE_FILE;
    URI uri;
    uri.setScheme("file");
    uri.setPath(path);
    return uri;
}
开发者ID:tribal-tec,项目名称:Brion,代码行数:11,代码来源:blueConfig.cpp

示例7: resolve

URI Transaction::resolve(const URI &_uri) {
  URI uri = _uri;

  if (uri.getHost().empty()) {
    uri.setHost(address.getHost());
    if (uri.getScheme().empty()) uri.setScheme("http");
    if (!uri.getPort()) uri.setPort(address.getPort());
  }

  return uri;
}
开发者ID:trasz,项目名称:cbang,代码行数:11,代码来源:Transaction.cpp

示例8: operator

bool RedirectSecure::operator()(Request &req) {
  if (req.isSecure()) return false; // Pass it on

  // Set scheme, host & port
  URI uri = req.getURI();
  uri.setScheme("https");
  uri.setHost(IPAddress(req.getHost()).getHost());
  uri.setPort(port == 443 ? 0 : port);

  // Redirect
  req.redirect(uri);

  return true;
}
开发者ID:CauldronDevelopmentLLC,项目名称:cbang,代码行数:14,代码来源:RedirectSecure.cpp

示例9: getProjectionSource

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;
}
开发者ID:tribal-tec,项目名称:Brion,代码行数:14,代码来源:blueConfig.cpp

示例10: getCircuitSource

URI BlueConfig::getCircuitSource() const
{
    const fs::path path(
        get(CONFIGSECTION_RUN, _impl->getRun(), BLUECONFIG_CIRCUIT_PATH_KEY));
    std::string filename = path.string();
    if (fs::exists(path) && !fs::is_regular_file(fs::canonical(path)))
    {
        filename = fs::exists(path / CIRCUIT_FILE_MVD3)
                       ? (path / CIRCUIT_FILE_MVD3).string()
                       : (path / CIRCUIT_FILE_MVD2).string();
    }
    URI uri;
    uri.setScheme("file");
    uri.setPath(filename);
    return uri;
}
开发者ID:tribal-tec,项目名称:Brion,代码行数:16,代码来源:blueConfig.cpp

示例11: testStreamOpenerFile

void URIStreamOpenerTest::testStreamOpenerFile()
{
	TemporaryFile tempFile;
	std::string path = tempFile.path();
	std::ofstream ostr(path.c_str());
	assert (ostr.good());
	ostr << "Hello, world!" << std::endl;
	ostr.close();
	
	URI uri;
	uri.setScheme("file");
	uri.setPath(Path(path).toString(Path::PATH_UNIX));
	std::string uriString = uri.toString();
	
	URIStreamOpener opener;
	std::istream* istr = opener.open(uri);
	assert (istr != 0);
	assert (istr->good());
	delete istr;
}
开发者ID:Victorcasas,项目名称:georest,代码行数:20,代码来源:URIStreamOpenerTest.cpp

示例12: testStreamOpenerURIResolve

void URIStreamOpenerTest::testStreamOpenerURIResolve()
{
	TemporaryFile tempFile;
	std::string path = tempFile.path();
	std::ofstream ostr(path.c_str());
	assert (ostr.good());
	ostr << "Hello, world!" << std::endl;
	ostr.close();
	
	Path p(path);
	p.makeAbsolute();
	Path parent(p.parent());
	
	URI uri;
	uri.setScheme("file");
	uri.setPath(parent.toString(Path::PATH_UNIX));
	std::string uriString = uri.toString();
	
	URIStreamOpener opener;
	std::istream* istr = opener.open(uriString, p.getFileName());
	assert (istr != 0);
	assert (istr->good());
	delete istr;
}
开发者ID:Victorcasas,项目名称:georest,代码行数:24,代码来源:URIStreamOpenerTest.cpp

示例13: testConstruction

void URITest::testConstruction()
{
	URI uri;
	assert (uri.getScheme().empty());
	assert (uri.getAuthority().empty());
	assert (uri.getUserInfo().empty());
	assert (uri.getHost().empty());
	assert (uri.getPort() == 0);
	assert (uri.getPath().empty());
	assert (uri.getQuery().empty());
	assert (uri.getFragment().empty());
	
	uri.setScheme("ftp");
	assert (uri.getScheme() == "ftp");
	assert (uri.getPort() == 21);
	
	uri.setScheme("HTTP");
	assert (uri.getScheme() == "http");
	
	uri.setAuthority("www.appinf.com");
	assert (uri.getAuthority() == "www.appinf.com");
	assert (uri.getPort() == 80);
	
	uri.setAuthority("[email protected]:8000");
	assert (uri.getUserInfo() == "user");
	assert (uri.getHost() == "services.appinf.com");
	assert (uri.getPort() == 8000);
	
	uri.setPath("/index.html");
	assert (uri.getPath() == "/index.html");
	
	uri.setPath("/file%20with%20spaces.html");
	assert (uri.getPath() == "/file with spaces.html");
	
	uri.setPathEtc("/query.cgi?query=foo");
	assert (uri.getPath() == "/query.cgi");
	assert (uri.getQuery() == "query=foo");
	assert (uri.getFragment().empty());
	assert (uri.getPathEtc() == "/query.cgi?query=foo");
	assert (uri.getPathAndQuery() == "/query.cgi?query=foo");
	
	uri.setPathEtc("/query.cgi?query=bar#frag");
	assert (uri.getPath() == "/query.cgi");
	assert (uri.getQuery() == "query=bar");
	assert (uri.getFragment() == "frag");
	assert (uri.getPathEtc() == "/query.cgi?query=bar#frag");
	assert (uri.getPathAndQuery() == "/query.cgi?query=bar");
	
	uri.setQuery("query=test");
	assert (uri.getQuery() == "query=test");
	
	uri.setFragment("result");
	assert (uri.getFragment() == "result");
	
	URI uri2("file", "/home/guenter/foo.bar");
	assert (uri2.getScheme() == "file");
	assert (uri2.getPath() == "/home/guenter/foo.bar");
	
	URI uri3("http", "www.appinf.com", "/index.html");
	assert (uri3.getScheme() == "http");
	assert (uri3.getAuthority() == "www.appinf.com");
	assert (uri3.getPath() == "/index.html");
	
	URI uri4("http", "www.appinf.com:8000", "/index.html");
	assert (uri4.getScheme() == "http");
	assert (uri4.getAuthority() == "www.appinf.com:8000");
	assert (uri4.getPath() == "/index.html");

	URI uri5("http", "[email protected]:8000", "/index.html");
	assert (uri5.getScheme() == "http");
	assert (uri5.getUserInfo() == "user");
	assert (uri5.getHost() == "www.appinf.com");
	assert (uri5.getPort() == 8000);
	assert (uri5.getAuthority() == "[email protected]:8000");
	assert (uri5.getPath() == "/index.html");

	URI uri6("http", "[email protected]:80", "/index.html");
	assert (uri6.getScheme() == "http");
	assert (uri6.getUserInfo() == "user");
	assert (uri6.getHost() == "www.appinf.com");
	assert (uri6.getPort() == 80);
	assert (uri6.getAuthority() == "[email protected]");
	assert (uri6.getPath() == "/index.html");

	URI uri7("http", "[email protected]:", "/index.html");
	assert (uri7.getScheme() == "http");
	assert (uri7.getUserInfo() == "user");
	assert (uri7.getHost() == "www.appinf.com");
	assert (uri7.getPort() == 80);
	assert (uri7.getAuthority() == "[email protected]");
	assert (uri7.getPath() == "/index.html");
	
	URI uri8("http", "www.appinf.com", "/index.html", "query=test");
	assert (uri8.getScheme() == "http");
	assert (uri8.getAuthority() == "www.appinf.com");
	assert (uri8.getPath() == "/index.html");
	assert (uri8.getQuery() == "query=test");

	URI uri9("http", "www.appinf.com", "/index.html", "query=test", "fragment");
	assert (uri9.getScheme() == "http");
//.........这里部分代码省略.........
开发者ID:Alcibiades586,项目名称:roadrunner,代码行数:101,代码来源:URITest.cpp

示例14: main

int main( int argc, char*argv[] ) {
   LOG_NOTICE( "Test Started" );

   URI u;

   u.setScheme( "http" );
   u.setAuthority( "www.jetheaddev.com" );
   u.setPath( "pages/index.html" );

   string ustr = u.getString();
   LOG_NOTICE( "URI is: %s", ustr.c_str() );

   for (uint32_t i = 0; i < ARRAY_SIZE( test_urls ); i++) {
      bool res = u.setString( test_urls[i] );

#ifdef DEBUG_PRINTS
      cout << "scheme: " << u.getScheme() << endl;
      cout << "authority: " << u.getAuthority() << endl;
      cout << "host: " << u.getHost() << endl;
      cout << "port: " << u.getPort() << endl;
      cout << "query: " << u.getQuery() << endl;
      cout << "path: " << u.getPath() << endl;
      cout << "fragment: " << u.getFragment() << endl;
      cout << "query param \"c\": " << u.getQueryParam( "c" ) << endl;
      cout << "query param \"e\": " << u.getQueryParam( "e" ) << endl;
      cout << "is relative: " << u.isRelative() << endl;
#endif

      if ( not res ) {
         LOG_WARN( "parse uri %s: FAILED", test_urls[i] );
         exit( 1 );
      } else {
         LOG_NOTICE( "parse uri %s: PASSED", test_urls[ i ] );
      }
   }

   u.clear();
   u.setScheme( "http" );
   u.setAuthority( "www.jetheaddev.com" );
   u.setPath( "pages/index.html" );
   u.appendQueryParam( "a", "b" );
   u.appendQueryParam( "c", "d" );
   u.setFragment( "m" );

   URI copy = u;

   ustr = u.getString();
   LOG_NOTICE( "URI is: %s", ustr.c_str() );
   ustr = copy.getString();
   LOG_NOTICE( "Copy is: %s", ustr.c_str() );

#ifdef DEBUG_PRINTS
   cout << "scheme: " << u.getScheme() << endl;
   cout << "scheme: " << copy.getScheme() << endl;
   cout << "authority: " << u.getAuthority() << endl;
   cout << "authority: " << copy.getAuthority() << endl;
   cout << "host: " << u.getHost() << endl;
   cout << "host: " << copy.getHost() << endl;
   cout << "port: " << u.getPort() << endl;
   cout << "port: " << copy.getPort() << endl;
   cout << "query: " << u.getQuery() << endl;
   cout << "query: " << copy.getQuery() << endl;
   cout << "path: " << u.getPath() << endl;
   cout << "path: " << copy.getPath() << endl;
   cout << "fragment: " << u.getFragment() << endl;
   cout << "fragment: " << copy.getFragment() << endl;
   cout << "query param \"a\": " << u.getQueryParam( "a" ) << endl;
   cout << "query param \"a\": " << copy.getQueryParam( "a" ) << endl;
   cout << "query param \"c\": " << u.getQueryParam( "c" ) << endl;
   cout << "query param \"c\": " << copy.getQueryParam( "c" ) << endl;
   cout << "is relative: " << u.isRelative() << endl;
   cout << "is relative: " << copy.isRelative() << endl;
#endif

   if ( u.getScheme() != copy.getScheme()
         or u.getAuthority() != copy.getAuthority()
         or u.getQuery() != copy.getQuery() or u.getPath() != copy.getPath()
         or u.getFragment() != copy.getFragment()
         or u.getQueryParam( "a" ) != copy.getQueryParam( "a" )
         or u.getQueryParam( "c" ) != copy.getQueryParam( "c" )
         or u.isRelative() != copy.isRelative() ) {
      LOG_WARN( "copy of uri: FAILED" );
   } else {
      LOG_NOTICE( "copy of uri: PASSED" );
   }

   return 0;
}
开发者ID:lmtan91,项目名称:common,代码行数:88,代码来源:URITest.cpp


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