本文整理汇总了C++中PSIn::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ PSIn::Len方法的具体用法?C++ PSIn::Len怎么用?C++ PSIn::Len使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSIn
的用法示例。
在下文中一共展示了PSIn::Len方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PutSIn
void TFRnd::PutSIn(const PSIn& SIn, TCs& Cs){
int BfL=SIn->Len();
char* Bf=new char[BfL];
SIn->GetBf(Bf, BfL);
Cs=TCs::GetCsFromBf(Bf, BfL);
PutBf(Bf, BfL);
delete[] Bf;
}
示例2: Send
void TSockSys::Send(const uint64& SockId, const PSIn& SIn) {
// make sure it's a valid socket
IAssert(IsSock(SockId));
uv_tcp_t* SockHnd = SockIdToHndH.GetDat(SockId);
// create write request
uv_write_req_t* WriteHnd = (uv_write_req_t*)malloc(sizeof(uv_write_req_t));
// copy the data in the buffer
WriteHnd->Buffer.len = SIn->Len(); //TODO: handle cases when SIn doesn't have known Len()
WriteHnd->Buffer.base = (char*)malloc(WriteHnd->Buffer.len);
SIn->GetBf(WriteHnd->Buffer.base, WriteHnd->Buffer.len);
// execute the request
int ResCd = uv_write((uv_write_t*)WriteHnd, (uv_stream_t*)SockHnd, &WriteHnd->Buffer, 1, OnWrite);
// check for errors
if (ResCd != 0) {
// cleanup first
free(WriteHnd->Buffer.base);
free(WriteHnd);
// and throw exception
throw TExcept::New("SockSys.Send: Error sending data: " + SockSys.GetLastErr());
}
}
示例3: PutBlob
TBlobPt TGBlobBs::PutBlob(const PSIn& SIn){
EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
int BfL=SIn->Len();
int MxBfL; int FFreeBlobPtN;
GetAllocInfo(BfL, BlockLenV, MxBfL, FFreeBlobPtN);
TBlobPt BlobPt; TCs Cs;
if (FFreeBlobPtV[FFreeBlobPtN].Empty()){
int FLen=FBlobBs->GetFLen();
if (FLen<=MxSegLen){
EAssert(FLen<=MxBlobFLen);
BlobPt=TBlobPt(FLen);
FBlobBs->SetFPos(BlobPt.GetAddr());
PutBlobTag(FBlobBs, btBegin);
FBlobBs->PutInt(MxBfL);
PutBlobState(FBlobBs, bsActive);
FBlobBs->PutInt(BfL);
FBlobBs->PutSIn(SIn, Cs);
FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
FBlobBs->PutCs(Cs);
PutBlobTag(FBlobBs, btEnd);
}
} else {
BlobPt=FFreeBlobPtV[FFreeBlobPtN];
FBlobBs->SetFPos(BlobPt.GetAddr());
AssertBlobTag(FBlobBs, btBegin);
int MxBfL=FBlobBs->GetInt();
int FPos=FBlobBs->GetFPos();
AssertBlobState(FBlobBs, bsFree);
FFreeBlobPtV[FFreeBlobPtN]=TBlobPt::LoadAddr(FBlobBs);
FBlobBs->SetFPos(FPos);
PutBlobState(FBlobBs, bsActive);
FBlobBs->PutInt(BfL);
FBlobBs->PutSIn(SIn, Cs);
FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
FBlobBs->PutCs(Cs);
AssertBlobTag(FBlobBs, btEnd);
}
FBlobBs->Flush();
return BlobPt;
}
示例4: Exec
void TSAppSrvFun::Exec(const TStrKdV& FldNmValPrV, const PSAppSrvRqEnv& RqEnv) {
const PNotify& Notify = RqEnv->GetWebSrv()->GetNotify();
PHttpResp HttpResp;
try {
// log the call
if (NotifyOnRequest)
Notify->OnStatus(TStr::Fmt("RequestStart %s", FunNm.CStr()));
TTmStopWatch StopWatch(true);
// execute the actual function, according to the type
PSIn BodySIn; TStr ContTypeVal;
if (GetFunOutType() == saotXml) {
PXmlDoc ResXmlDoc = ExecXml(FldNmValPrV, RqEnv);
TStr ResXmlStr; ResXmlDoc->SaveStr(ResXmlStr);
BodySIn = TMIn::New(XmlHdStr + ResXmlStr);
ContTypeVal = THttp::TextXmlFldVal;
} else if (GetFunOutType() == saotJSon) {
TStr ResStr = ExecJSon(FldNmValPrV, RqEnv);
BodySIn = TMIn::New(ResStr);
ContTypeVal = THttp::AppJSonFldVal;
} else {
BodySIn = ExecSIn(FldNmValPrV, RqEnv, ContTypeVal);
}
if (ReportResponseSize)
Notify->OnStatusFmt("Response size: %.1f KB", BodySIn->Len() / (double) TInt::Kilo);
// log finish of the call
if (NotifyOnRequest)
Notify->OnStatus(TStr::Fmt("RequestFinish %s [request took %d ms]", FunNm.CStr(), StopWatch.GetMSecInt()));
// prepare response
HttpResp = THttpResp::New(THttp::OkStatusCd,
ContTypeVal, false, BodySIn);
} catch (PExcept Except) {
// known internal error
Notify->OnStatusFmt("Exception: %s", Except->GetMsgStr().CStr());
Notify->OnStatusFmt("Location: %s", Except->GetLocStr().CStr());
TStr ResStr, ContTypeVal = THttp::TextPlainFldVal;
if (GetFunOutType() == saotXml) {
PXmlTok TopTok = TXmlTok::New("error");
TopTok->AddSubTok(TXmlTok::New("message", Except->GetMsgStr()));
TopTok->AddSubTok(TXmlTok::New("location", Except->GetLocStr()));
PXmlDoc ErrorXmlDoc = TXmlDoc::New(TopTok);
ResStr = XmlHdStr + ErrorXmlDoc->SaveStr();
ContTypeVal = THttp::TextXmlFldVal;
} else if (GetFunOutType() == saotJSon) {
PJsonVal ResVal = TJsonVal::NewObj();
ResVal->AddToObj("message", Except->GetMsgStr());
ResVal->AddToObj("location", Except->GetLocStr());
ResStr = TJsonVal::NewObj("error", ResVal)->SaveStr();
ContTypeVal = THttp::AppJSonFldVal;
}
// prepare response
HttpResp = THttpResp::New(THttp::InternalErrStatusCd,
ContTypeVal, false, TMIn::New(ResStr));
} catch (...) {
// unknown internal error
TStr ResStr, ContTypeVal = THttp::TextPlainFldVal;
if (GetFunOutType() == saotXml) {
PXmlDoc ErrorXmlDoc = TXmlDoc::New(TXmlTok::New("error"));
ResStr = XmlHdStr + ErrorXmlDoc->SaveStr();
ContTypeVal = THttp::TextXmlFldVal;
} else if (GetFunOutType() == saotJSon) {
ResStr = TJsonVal::NewObj("error", "Unknown")->SaveStr();
ContTypeVal = THttp::AppJSonFldVal;
}
// prepare response
HttpResp = THttpResp::New(THttp::InternalErrStatusCd,
ContTypeVal, false, TMIn::New(ResStr));
}
if (LogRqToFile)
LogReqRes(FldNmValPrV, HttpResp);
// send response
RqEnv->GetWebSrv()->SendHttpResp(RqEnv->GetSockId(), HttpResp);
}
示例5: Len
int Len(){return EofChPrS.Len()+SIn->Len();}