本文整理匯總了C++中EAssertR函數的典型用法代碼示例。如果您正苦於以下問題:C++ EAssertR函數的具體用法?C++ EAssertR怎麽用?C++ EAssertR使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EAssertR函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: IsOk
bool TNEANetMP::IsOk(const bool& ThrowExcept) const {
bool RetVal = true;
for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
const TNode& Node = NodeH[N];
if (! Node.OutEIdV.IsSorted()) {
const TStr Msg = TStr::Fmt("Out-edge list of node %d is not sorted.", Node.GetId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
if (! Node.InEIdV.IsSorted()) {
const TStr Msg = TStr::Fmt("In-edge list of node %d is not sorted.", Node.GetId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
// check out-edge ids
int prevEId = -1;
for (int e = 0; e < Node.GetOutDeg(); e++) {
if (! IsEdge(Node.GetOutEId(e))) {
const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetOutEId(e), Node.GetId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
if (e > 0 && prevEId == Node.GetOutEId(e)) {
const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetOutEId(e));
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
prevEId = Node.GetOutEId(e);
}
// check in-edge ids
prevEId = -1;
for (int e = 0; e < Node.GetInDeg(); e++) {
if (! IsEdge(Node.GetInEId(e))) {
const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetInEId(e), Node.GetId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
if (e > 0 && prevEId == Node.GetInEId(e)) {
const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetInEId(e));
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
prevEId = Node.GetInEId(e);
}
}
for (int E = EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
const TEdge& Edge = EdgeH[E];
if (! IsNode(Edge.GetSrcNId())) {
const TStr Msg = TStr::Fmt("Edge %d source node %d does not exist.", Edge.GetId(), Edge.GetSrcNId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
if (! IsNode(Edge.GetDstNId())) {
const TStr Msg = TStr::Fmt("Edge %d destination node %d does not exist.", Edge.GetId(), Edge.GetDstNId());
if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
}
}
return RetVal;
}
示例2: HandleScope
void TNodeJsFs::openRead(const v8::FunctionCallbackInfo<v8::Value>& Args) {
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::HandleScope HandleScope(Isolate);
EAssertR(Args.Length() == 1 && Args[0]->IsString(), "Expected file path.");
TStr FNm(*v8::String::Utf8Value(Args[0]->ToString()));
// file exist check is done by TFIn
Args.GetReturnValue().Set(
TNodeJsUtil::NewInstance<TNodeJsFIn>(new TNodeJsFIn(FNm)));
}
示例3: Split
void TFtrGenSparseNumeric::Add(const TStr& Str, TIntFltKdV& SpV, int& Offset) const {
TStrV EltV; Str.SplitOnAllCh(';', EltV); TIntH UsedIdH;
for (int EltN = 0; EltN < EltV.Len(); EltN++) {
int Id; TStr Val; Split(EltV[EltN], Id, Val);
EAssertR(!UsedIdH.IsKey(Id), "Field ID repeated in '" + Str + "'!");
int TmpOffset = Offset + Id;
FtrGen->Add(Val, SpV, TmpOffset);
UsedIdH.AddKey(Id);
}
Offset += GetVals();
}
示例4: HandleScope
v8::Local<v8::Function> TNodeJsUtil::GetFldFun(v8::Local<v8::Object> Obj, const TStr& FldNm) {
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::HandleScope HandleScope(Isolate);
EAssertR(IsFldFun(Obj, FldNm), "The field is not a function!");
v8::Local<v8::Value> FldVal = Obj->Get(v8::String::NewFromUtf8(Isolate, FldNm.CStr()));
v8::Local<v8::Function> RetFun = v8::Handle<v8::Function>::Cast(FldVal);
return RetFun;
}
示例5: HandleScope
v8::Local<v8::Object> TNodeJsSA::New(TWPt<TQm::TStreamAggr> _SA) {
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope HandleScope(Isolate);
EAssertR(!constructor.IsEmpty(), "TNodeJsSA::New: constructor is empty. Did you call TNodeJsSA::Init(exports); in this module's init function?");
v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(Isolate, constructor);
v8::Local<v8::Object> Instance = cons->NewInstance();
TNodeJsSA* JsSA = new TNodeJsSA(_SA);
JsSA->Wrap(Instance);
return HandleScope.Escape(Instance);
}
示例6: TSBase
TFOut::TFOut(const TStr& FNm, const bool& Append):
TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){
if (FNm.GetUc()=="CON"){
FileId=stdout;
} else {
if (Append){FileId=fopen(FNm.CStr(), "a+b");}
else {FileId=fopen(FNm.CStr(), "w+b");}
EAssertR(FileId!=NULL, "Can not open file '"+FNm+"'.");
Bf=new char[MxBfL]; BfL=0;
}
}
示例7: EAssertR
void TGraphCascade::ObserveNode(const TStr& NodeNm, const uint64& Time) {
if (!NodeNmIdH.IsKey(NodeNm)) {
// skip, we do not use this node
return;
}
int NodeId = NodeNmIdH.GetDat(NodeNm);
if (!Graph.IsNode(NodeId)) { return; } // skip, we do not use this node
// Assert that causality is OK, throw exception if it's violated
EAssertR(Timestamps.GetDat(NodeId) < Time, "TGraphCascade::ObserveNode: the node `" + NodeNm + "` was observed too late given causal constraints");
Timestamps.AddDat(NodeId, Time);
}
示例8: EAssertR
void TNodeJsFOut::New(const v8::FunctionCallbackInfo<v8::Value>& Args) {
EAssertR(Args.IsConstructCall(), "TNodeJsFOut: not a constructor call (you forgot to use the new operator)");
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope HandleScope(Isolate);
// set hidden class id
v8::Local<v8::Object> Instance = Args.This();
v8::Handle<v8::String> key = v8::String::NewFromUtf8(Isolate, "class");
v8::Handle<v8::String> value = v8::String::NewFromUtf8(Isolate, GetClassId().CStr());
Instance->SetHiddenValue(key, value);
// empty constructor call just forwards the instance
if (Args.Length() == 0) { Args.GetReturnValue().Set(Instance); return; }
// parse arguments
EAssertR(Args.Length() >= 1 && Args[0]->IsString(),
"Expected file path.");
TStr FNm(*v8::String::Utf8Value(Args[0]->ToString()));
bool AppendP = Args.Length() >= 2 && Args[1]->IsBoolean() && Args[1]->BooleanValue();
// Args.This() is an instance, wrap our C++ object
TNodeJsFOut* Obj = new TNodeJsFOut(FNm, AppendP);
Obj->Wrap(Instance);
Args.GetReturnValue().Set(Instance);
}
示例9: EAssertR
void TBagOfWords::GetFtr(const TStr& Str, TStrV& TokenStrV) const {
// outsource to tokenizer
EAssertR(!Tokenizer.Empty(), "Missing tokenizer in TFtrGen::TBagOfWords");
Tokenizer->GetTokens(Str, TokenStrV);
// counting average token length
/*static int Count = 0, LenStr = 0, LenVec = 0;
Count++; LenStr += Str.Len(); LenVec += TokenStrV.Len();
if (Count % 1000 == 0) {
printf("Average token length[docs=%d chars=%d words=%d length=%.4f\n",
Count, LenStr, LenVec, (double)LenStr / (double)LenVec);
}*/
}
示例10: WindowSize
TNearestNeighbor::TNearestNeighbor(const double& Rate, const int& _WindowSize):
WindowSize(_WindowSize) {
// assert rate parameter range
EAssertR(0.0 < Rate && Rate < 1.0, "TAnomalyDetection::TNearestNeighbor: Rate parameter not > 0.0 and < 1.0");
// remember the rate
RateV.Add(Rate);
// initialize all vectors to window size
Mat.Gen(WindowSize, 0);
DistV.Gen(WindowSize, 0);
DistColV.Gen(WindowSize, 0);
IDVec.Gen(WindowSize, 0);
}
示例11: AssertR
double TLinear::Interpolate(const uint64& Tm) const {
AssertR(CanInterpolate(Tm), "TLinear::Interpolate: Time not in the desired interval!");
const TUInt64FltPr& PrevRec = Buff.GetOldest();
if (Tm == PrevRec.Val1) { return PrevRec.Val2; }
const TUInt64FltPr& NextRec = Buff.GetOldest(1);
// don't need to check if the times of the previous rec and next rec are equal since if
// that is true Tm will be equal to PrevRec.Tm and the correct result will be returned
const double Result = PrevRec.Val2 + ((double) (Tm - PrevRec.Val1) / (NextRec.Val1 - PrevRec.Val1)) * (NextRec.Val2 - PrevRec.Val2);
EAssertR(!TFlt::IsNan(Result), "TLinear: result of interpolation is NaN!");
return Result;
}
示例12: RateV
TNearestNeighbor::TNearestNeighbor(const TFltV& _RateV, const int& _WindowSize):
RateV(_RateV), WindowSize(_WindowSize) {
// assert rate parameter range
for (const double Rate : RateV) {
EAssertR(0.0 < Rate && Rate < 1.0, "TAnomalyDetection::TNearestNeighbor: Rate parameter not > 0.0 and < 1.0");
}
// initialize all vectors to window size
Mat.Gen(WindowSize, 0);
DistV.Gen(WindowSize, 0);
DistColV.Gen(WindowSize, 0);
DatV.Gen(WindowSize, 0);
}
示例13: while
void TCurrentPoint::SetNextInterpTm(const uint64& Tm) {
// at least one past (or current time) record needs to be in the buffer
bool Change = false;
while (Buff.Len() >= 2 && Buff.GetOldest(1).Val1 <= Tm) {
Buff.DelOldest();
Change = true;
}
if (Change) {
EAssertR(CanInterpolate(Tm), "WTF!? Current point interpolator cannot intrpolate after setting new time!");
}
// when the loop finishes we have at least 1 record in the buffer
// with a timestamp <= Tm
}
示例14: TSBase
TZipIn::TZipIn(const TStr& FNm, bool& OpenedP) : TSBase(), TSIn(), ZipStdoutRd(NULL), ZipStdoutWr(NULL), SNm(FNm.CStr()),
FLen(0), CurFPos(0), Bf(NULL), BfC(0), BfL(0) {
EAssertR(! FNm.Empty(), "Empty file-name.");
FLen = TZipIn::GetFLen(FNm);
OpenedP = TFile::Exists(FNm);
if (OpenedP) {
#ifdef GLib_WIN
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
// Create a pipe for the child process's STDOUT.
EAssertR(CreatePipe(&ZipStdoutRd, &ZipStdoutWr, &saAttr, 0), "Stdout pipe creation failed");
// Ensure the read handle to the pipe for STDOUT is not inherited.
SetHandleInformation(ZipStdoutRd, HANDLE_FLAG_INHERIT, 0);
#else
// no implementation needed
#endif
CreateZipProcess(GetCmd(FNm.GetFExt()), FNm);
Bf = new char[MxBfL]; BfC = BfL=-1;
FillBf();
}
}
示例15: Clr
const char* TJsonObj::ParseArrayVal(const char* JsonStr) {
const char *c = JsonStr;
bool Nested = false;
TChA ValStr;
Clr();
while (*c && TCh::IsWs(*c)) { c++; }
if (*c == '"') { c = GetStr(c, ValStr); } // string
else if (TCh::IsNum(*c) || (*c=='-' && TCh::IsNum(*(c+1)))) { // number
while (*c && *c!=',' && *c!='}' && *c!=']' && ! TCh::IsWs(*c)) { ValStr.Push(*c); c++; } }
else if (*c=='t' || *c=='f' || *c=='n') { // true, false, null
while (*c && *c!=',' && *c!='}' && *c!=']') { ValStr.Push(*c); c++; } }
else if (*c=='{') { // nested object
EAssertR(! KeyArrayH.IsKey("key"), "JSON error: object with key 'key' already exists");
TJsonObj& Obj = KeyObjH.AddDat("key");
c = Obj.Parse(c) + 1; Nested = true;
}
else if (*c=='[') { // array
EAssertR(! KeyArrayH.IsKey("key"), "JSON error: array with key 'key' already exists");
TVec<TJsonObj>& Array = KeyArrayH.AddDat("key");
c++;
while (*c && *c!=']') {
while (*c && TCh::IsWs(*c)) { c++; }
Array.Add();
if (*c=='{') { c = Array.Last().Parse(c) + 1; } // nested object
else { c = Array.Last().ParseArrayVal(c); }
if (*c && *c==',') { c++; }
}
c++; Nested = true;
}
if (! Nested) {
EAssertR(! KeyArrayH.IsKey("key"), "JSON error: object with key 'key' already exists");
KeyValH.AddDat("key", ValStr);
}
while (*c && TCh::IsWs(*c)) { c++; }
return c;
}