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


C++ EAssertR函数代码示例

本文整理汇总了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;
}
开发者ID:shubhamg31,项目名称:snapr,代码行数:52,代码来源:networkmp.cpp

示例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)));
}
开发者ID:quintelligence,项目名称:qminer,代码行数:11,代码来源:fs_nodejs.cpp

示例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();
}
开发者ID:mkarlovc,项目名称:gcentralization,代码行数:11,代码来源:ftrgen.cpp

示例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;
}
开发者ID:amrsobhy,项目名称:qminer,代码行数:11,代码来源:nodeutil.cpp

示例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);
}
开发者ID:Zala,项目名称:qminer,代码行数:11,代码来源:qm_nodejs_streamaggr.cpp

示例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;
  }
}
开发者ID:andrejmuhic,项目名称:qminer,代码行数:11,代码来源:fl.cpp

示例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);
}
开发者ID:Bradeskojest,项目名称:qminer,代码行数:11,代码来源:graphprocess.cpp

示例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);	
}
开发者ID:quintelligence,项目名称:qminer,代码行数:21,代码来源:fs_nodejs.cpp

示例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);
    }*/
}
开发者ID:joaopitacosta,项目名称:qminer,代码行数:12,代码来源:ftrgen.cpp

示例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);
}
开发者ID:blazs,项目名称:qminer,代码行数:13,代码来源:anomaly.cpp

示例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;
}
开发者ID:amrsobhy,项目名称:qminer,代码行数:13,代码来源:signalproc.cpp

示例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);
}
开发者ID:gregorleban,项目名称:Qminer,代码行数:13,代码来源:anomaly.cpp

示例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
}
开发者ID:amrsobhy,项目名称:qminer,代码行数:13,代码来源:signalproc.cpp

示例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();
  }
}
开发者ID:Bradeskojest,项目名称:qminer,代码行数:23,代码来源:zipfl.cpp

示例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;
}
开发者ID:Networks-Learning,项目名称:infopath,代码行数:36,代码来源:json.cpp


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