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


C++ ws函数代码示例

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


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

示例1: ws

PointGFp operator*(const BigInt& scalar, const PointGFp& point)
   {
   //BOTAN_ASSERT(point.on_the_curve(), "Input is on the curve");

   const CurveGFp& curve = point.get_curve();

   const size_t scalar_bits = scalar.bits();

   std::vector<BigInt> ws(9);

   if(scalar_bits <= 2)
      {
      const byte abs_val = scalar.byte_at(0);

      if(abs_val == 0)
         return PointGFp::zero_of(curve);

      PointGFp result = point;

      if(abs_val == 2)
         result.mult2(ws);

      if(scalar.is_negative())
         result.negate();

      return result;
      }

   PointGFp R[2] = { PointGFp(curve), point };

   for(size_t i = scalar_bits; i > 0; i--)
      {
      const size_t b = scalar.get_bit(i - 1);
      R[b ^ 1].add(R[b], ws);
      R[b].mult2(ws);
      }

   if(scalar.is_negative())
      R[0].negate();

   //BOTAN_ASSERT(R[0].on_the_curve(), "Output is on the curve");

   return R[0];
   }
开发者ID:Jesse-V,项目名称:botan,代码行数:44,代码来源:point_gfp.cpp

示例2: switch

void CSitFactInterpretation::FillConstFieldValue(const fact_field_reference_t& fact_field, yvector<CFactFields>& newFacts, const SWordHomonymNum& valValue)
{
    const CWord& w = m_Words.GetWord(valValue);
    switch (fact_field.m_Field_type) {
        case TextField: {
            CTextWS ws;
            ws.SetArtificialPair(w.GetSourcePair());
            ws.AddLemma(SWordSequenceLemma(fact_field.m_StringValue));
            FillWSFactField(fact_field, ws, newFacts);
            break;
        } case BoolField: {
            CBoolWS ws(fact_field.m_bBoolValue);
            ws.SetPair(w.GetSourcePair());
            FillWSFactField(fact_field, ws, newFacts);
            break;
        } default:
            break;
    }
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:19,代码来源:sitfactinterpretation.cpp

示例3: main

int main(int, char*[])
{
    util::BackgroundScheduler poller;
    util::WorkerThreadPool wtp(util::WorkerThreadPool::NORMAL);

    util::http::Client wc;
    util::http::Server ws(&poller, &wtp);

    unsigned rc = ws.Init();

    EchoContentFactory ecf;
    ws.AddContentFactory("/", &ecf);

    assert(rc == 0);

    std::string url = (boost::format("http://127.0.0.1:%u/zootle/wurdle.html")
		       % ws.GetPort()
	).str();

    util::CountedPointer<FetchTask> ft(new FetchTask(url, &wc, &poller));

    wtp.PushTask(util::Bind(ft).To<&FetchTask::Run>());

    time_t start = time(NULL);
    time_t finish = start+5;
    time_t now;

    do {
	now = time(NULL);
	if (now < finish)
	{
//	    TRACE << "polling for " << (finish-now)*1000 << "ms\n";
	    poller.Poll((unsigned)(finish-now)*1000);
	}
    } while (now < finish && !ft->IsDone());

//    TRACE << "Got '" << ft->GetContents() << "' (len "
//	  << strlen(ft->GetContents().c_str()) << " sz "
//	  << ft->GetContents().length() << ")\n";
    assert(ft->GetContents() == "/zootle/wurdle.html");

    return 0;
}
开发者ID:pdh11,项目名称:chorale,代码行数:43,代码来源:http_stream.cpp

示例4: main

int main(int argc, char *argv[])
{
    SDLApplication sdlapp;
    //std::unique_ptr<INScene> app;
    std::unique_ptr<GLWindowBase> app;
    int exitCode = 0;
    try
    {
        app.reset(new INScene(&sdlapp, 1280, 720));
        //app.reset(new TestTextures(&sdlapp, 1280, 720));

        sdlapp.mainLoop();
    }
    catch (VTF::Exception& e)
    {
        DebugLogV(e.getMessage().c_str());
        exitCode = e.getExitCode();
    }
    catch (std::exception& e)
    {
        DebugLogV(e.what());
        exitCode = -1;
    }
    catch(const char* str)
    {
        DebugLogV(str);
        exitCode = -1;
    }
    catch(const wchar_t* str)
    {
        std::wstring ws( str );
        std::string s( ws.begin(), ws.end() );
        DebugLogV(s.c_str());
        exitCode = -1;
    }
    catch(...)
    {
        DebugLogV("Unknown error");
        exitCode = -1;
    }
    app.reset();
    return exitCode;
}
开发者ID:kamillys,项目名称:IN_SDL_Demo,代码行数:43,代码来源:main.cpp

示例5: Q_D

void QDebugMessageService::sendDebugMessage(QtMsgType type,
                                            const QMessageLogContext &ctxt,
                                            const QString &buf)
{
    Q_D(QDebugMessageService);

    //We do not want to alter the message handling mechanism
    //We just eavesdrop and forward the messages to a port
    //only if a client is connected to it.
    QByteArray message;
    QQmlDebugStream ws(&message, QIODevice::WriteOnly);
    ws << QByteArray("MESSAGE") << type << buf.toUtf8();
    ws << QString::fromLatin1(ctxt.file).toUtf8();
    ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8();

    sendMessage(message);
    if (d->oldMsgHandler)
        (*d->oldMsgHandler)(type, ctxt, buf);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:19,代码来源:qdebugmessageservice.cpp

示例6: getInput

void GoblinTask::createEnergyList()
{
  std::string name = getInput("Enter name for new EnergyList");
  if (!name.empty())
  {
    try
    {
      API::TableWorkspace_ptr ws( dynamic_cast<API::TableWorkspace*>(
        API::WorkspaceFactory::instance().create("EnergyList")  ));
      API::WorkspaceManager::instance().addOrReplace(name,ws);
      QtAPI::SubWindow* wnd = QtAPI::WindowManager::instance().createSubWindow(new QtAPI::Table(ws));
      wnd->setWindowTitle(QString::fromStdString(name));
    }
    catch(std::exception& e)
    {
      errorMessage(std::string("Creating EnergyList failed:\n")+e.what());
    }
  }
}
开发者ID:rrnntt,项目名称:SmallProject,代码行数:19,代码来源:GoblinTask.cpp

示例7: sLoadBom

NAMESPACE_UPP

static void sLoadBom(Stream& in, String *t, WString *wt, byte def_charset) 
{
	if(in.IsOpen()) {
		String s;
		if(in.GetLeft() > 3) {
			word header = in.Get16le();
			if(header == 0xfffe || header == 0xfeff) {
				int n = (int)in.GetLeft() / 2;
				WStringBuffer ws(n);
				ws.SetLength(in.Get(~ws, 2 * n) / 2);
				if(header == 0xfffe)
					EndianSwap((word *)~ws, ws.GetCount());
				if(wt)
					*wt = ws;
				else
					*t = FromUnicode(ws);
				return;
			}
			int c = in.Get();
			if(c < 0)
				return;
			byte *h = (byte *)&header;
			if(h[0] == 0xef && h[1] == 0xbb && c == 0xbf) {
				if(wt)
					*wt = FromUtf8(LoadStream(in));
				else
					*t = ToCharset(CHARSET_DEFAULT, LoadStream(in), CHARSET_UTF8);
				return;
			}
			s.Cat(h, 2);
			s.Cat(c);
		}
		s.Cat(LoadStream(in));
		if(wt)
			*wt = ToUnicode(s, def_charset);
		else
			*t = ToCharset(CHARSET_DEFAULT, s, def_charset);
		return;
	}
	return;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:43,代码来源:Bom.cpp

示例8: CoCreateGuid

std::string LoginSession::CreateGuid()
{
#ifdef _WIN32
    GUID output;
    CoCreateGuid(&output);
    OLECHAR* guidString;
    StringFromCLSID(output, &guidString);

    std::wstring ws( guidString );
    std::string test( ws.begin(), ws.end() );

    return test;
#else
    uuid_t id;
    uuid_generate(id);
    char guidString[256];
    uuid_unparse(id, guidString);
    return std::string(guidString);
#endif
}
开发者ID:ArahEmu,项目名称:gate-server,代码行数:20,代码来源:loginsession.cpp

示例9: serialized

void CBBListenerImpl::PutTupleL(const TTupleName& aTuple,
	const TDesC& aSubName, const MBBData* aData, const TTime& aExpires)
{
	if (!aData) {
		TRequestStatus s;
		iBBClient.Delete(aTuple, aSubName, s);
		User::WaitForRequest(s);
		if (s.Int()==KErrNone || s.Int()==KErrNotFound) return;
		User::Leave(s.Int());
	}

	auto_ptr<HBufC8> serialized(HBufC8::NewL(1024));
	TInt err=KErrOverflow;
	while (err==KErrOverflow) {
		TPtr8 bufp(serialized->Des());
		RDesWriteStream ws(bufp);

		aData->Type().ExternalizeL(ws);
		CC_TRAP(err, aData->ExternalizeL(ws));
		if (err==KErrNone) {
			ws.CommitL();
		} else if (err==KErrOverflow) {
			serialized.reset( HBufC8::NewL(
				serialized->Des().MaxLength()*2) );
		}
	}
	User::LeaveIfError(err);

	TUint id;
	TRequestStatus s;

	TBool replace=ETrue;
	if (aTuple==KRemoteLocaLogicTuple) replace=EFalse;
	if (aTuple==KRemoteBluetoothTuple) replace=EFalse;

	iBBClient.Put(aTuple, aSubName,
		KNoComponent, *serialized, EBBPriorityNormal,
		replace, id, s, aExpires, ETrue, EFalse);
	User::WaitForRequest(s);
	User::LeaveIfError(s.Int());
}
开发者ID:flaithbheartaigh,项目名称:jaikuengine-mobile-client,代码行数:41,代码来源:bb_listener.cpp

示例10: getProperty

/** Create an empty output workspace from the generic properies. This gives a
new workspace with dimensions provided, but signal and
error arrays will not yet be set.
*/
MDHistoWorkspace_sptr ImportMDHistoWorkspaceBase::createEmptyOutputWorkspace() {
  // Fetch input properties
  size_t ndims;
  {
    int ndims_int = getProperty("Dimensionality");
    ndims = ndims_int;
  }
  std::vector<double> extents = getProperty("Extents");
  std::vector<int> nbins = getProperty("NumberOfBins");
  std::vector<std::string> names = getProperty("Names");
  std::vector<std::string> units = getProperty("Units");

  // Perform all validation on inputs
  if (extents.size() != ndims * 2)
    throw std::invalid_argument("You must specify twice as many extents "
                                "(min,max) as there are dimensions.");
  if (nbins.size() != ndims)
    throw std::invalid_argument(
        "You must specify as number of bins as there are dimensions.");
  if (names.size() != ndims)
    throw std::invalid_argument(
        "You must specify as many names as there are dimensions.");
  if (units.size() != ndims)
    throw std::invalid_argument(
        "You must specify as many units as there are dimensions.");

  // Fabricate new dimensions from inputs
  std::vector<MDHistoDimension_sptr> dimensions;
  for (size_t k = 0; k < ndims; ++k) {
    dimensions.push_back(MDHistoDimension_sptr(new MDHistoDimension(
        names[k], names[k], units[k], static_cast<coord_t>(extents[k * 2]),
        static_cast<coord_t>(extents[(k * 2) + 1]), nbins[k])));
  }

  // Calculate the total number of bins by multiplying across each dimension.
  Product answer = std::for_each(nbins.begin(), nbins.end(), Product());
  m_bin_product = answer.result;

  MDHistoWorkspace_sptr ws(new MDHistoWorkspace(dimensions));
  return ws;
}
开发者ID:nimgould,项目名称:mantid,代码行数:45,代码来源:ImportMDHistoWorkspaceBase.cpp

示例11: ws

void WebSocketRequestHandler::handleRequest
(HTTPServerRequest& request, HTTPServerResponse& response)
{
    Application& app = Application::instance();
    try
    {
        WebSocket ws(request, response);
        app.logger().information("WebSocket connection established.");
        char buffer[1024];
        int flags;
        int n;
        do
        {
            n = ws.receiveFrame(buffer, sizeof(buffer), flags);
            app.logger().information(Poco::format("Frame received (length=%d, flags=0x%x).", 
                                                  n, 
                                                  unsigned(flags)));
            ws.sendFrame(buffer, n, flags);
        }

        while (n > 0 || (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE);
        app.logger().information("WebSocket connection closed.");
     }
     catch (WebSocketException& exc)
     {
         app.logger().log(exc);
         switch (exc.code())
         {
             case WebSocket::WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION:
                 response.set("Sec-WebSocket-Version", WebSocket::WEBSOCKET_VERSION);
                 // fallthrough
             case WebSocket::WS_ERR_NO_HANDSHAKE:
             case WebSocket::WS_ERR_HANDSHAKE_NO_VERSION:
             case WebSocket::WS_ERR_HANDSHAKE_NO_KEY:
                 response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
                 response.setContentLength(0);
                 response.send();
                 break;
         }
     }
}
开发者ID:oldoak,项目名称:sandbox,代码行数:41,代码来源:WebSocketRequestHandler.C

示例12: upload

static bool upload(const char* addr, const char* filepath)
{
	acl::socket_stream conn;
	if (conn.open(addr, 30, 30) == false)
	{
		printf("connect %s error %s\r\n", addr, acl::last_serror());
		return false;
	}

	if (handshake(conn) == false)
		return false;

	acl::websocket ws(conn);

	if (send_file(ws, filepath) == false)
		return false;

	if (read_reply(ws) == false)
		return false;
	return true;
}
开发者ID:LazyPlanet,项目名称:acl,代码行数:21,代码来源:main.cpp

示例13: main

int main(int argc, char *argv[])
{
	if (argc < 2) {
		std::cerr << "Usage: " << argv[0] << " <url>" << std::endl;
		return 1;
	}

	WebSource ws(argv[1]);
	svi::SimpleVideoInput v(ws);
	cv::Mat image;
	int count = 0;
	while (v.read(image)) {
		std::cout << "Read Frame #" << count++ << " (" << v.millisecondsPerFrame() << "ms)" << std::endl;

		cv::imshow("Current frame", image);
		if (cv::waitKey(1) == 'q')
			break;
	}

	return 0;
}
开发者ID:ruathudo,项目名称:SimpleVideoInput,代码行数:21,代码来源:web_source.cpp

示例14: ws

GdaCache::GdaCache()
{
    wxString exePath = GdaCache::GetFullPath();
#ifdef __WIN32__
	std::wstring ws(GET_ENCODED_FILENAME(exePath));
	std::string s(ws.begin(), ws.end());
	cache_filename = s;
#else
	cache_filename = GET_ENCODED_FILENAME(exePath);
#endif
    
	// if cache file not exists, create one
    if (!wxFileExists(exePath)) {
        OGRDatasourceProxy::CreateDataSource("SQLite", cache_filename);
    }
    
	// connect to cache file
    try {
        cach_ds_proxy = new OGRDatasourceProxy(cache_filename, true);
        layer_names = cach_ds_proxy->GetLayerNames();
        std::string sql = "SELECT * FROM history";
        history_table = cach_ds_proxy->GetLayerProxyBySQL(sql);
        
        if (history_table == NULL) {
            sql = "CREATE TABLE history (param_key TEXT, param_val TEXT)";
            cach_ds_proxy->ExecuteSQL(sql);
            sql = "SELECT * FROM history";
            history_table = cach_ds_proxy->GetLayerProxyBySQL(sql);
        }
        
        history_table->ReadData();
        
        for ( int i=0; i< history_table->n_rows; i++){
            history_keys.push_back( history_table->GetValueAt(i, 0).ToStdString() );
            history_vals.push_back( history_table->GetValueAt(i, 1).ToStdString() );
        }
    }catch(GdaException& e) {
        //XXX
    }
}
开发者ID:jontheepi,项目名称:geoda,代码行数:40,代码来源:GdaCache.cpp

示例15: LOG

void client_request_handler::handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{
  try
  {
    LOG("Request for client connection");
    
    // any exceptions thrown on WebSocket handshake or client validation
    // will lead to not registering client
    ws_t ws(new WebSocket(request, response));
    client_t h(new client(ws));
    h->init();
    
    CLIENTS.add(h);
  }
  catch (const WebSocketException& exc)
  {
    LOGERROR(exc.displayText());
    switch (exc.code())
    {
    case WebSocket::WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION:
      response.set("Sec-WebSocket-Version", WebSocket::WEBSOCKET_VERSION);
      // fallthrough
    case WebSocket::WS_ERR_NO_HANDSHAKE:
    case WebSocket::WS_ERR_HANDSHAKE_NO_VERSION:
    case WebSocket::WS_ERR_HANDSHAKE_NO_KEY:
      response.setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
      response.setContentLength(0);
      response.send();
      break;
    }
  }
  catch (const Exception& e)
  {
    LOGERROR(e.displayText());
  }
  catch (const exception& e)
  {
    LOGERROR(e.what());
  }
}
开发者ID:wozio,项目名称:home-system,代码行数:40,代码来源:client_request_handler.cpp


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