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


C++ RAISE_ERROR函数代码示例

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


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

示例1: get_gzip_eof

static const char* get_gzip_eof( FILE* file, long* eof )
{
	unsigned char buf [4];
	if ( !fread( buf, 2, 1, file ) )
		RAISE_ERROR( "Couldn't read from file" );
	
	if ( buf [0] == 0x1F && buf [1] == 0x8B )
	{
		if ( fseek( file, -4, SEEK_END ) )
			RAISE_ERROR( "Couldn't seek in file" );
		
		if ( !fread( buf, 4, 1, file ) )
			RAISE_ERROR( "Couldn't read from file" );
		
		*eof = buf [3] * 0x1000000L + buf [2] * 0x10000L + buf [1] * 0x100L + buf [0];
	}
	else
	{
		if ( fseek( file, 0, SEEK_END ) )
			RAISE_ERROR( "Couldn't seek in file" );
		
		*eof = ftell( file );
	}
	
	return 0;
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:26,代码来源:abstract_file.cpp

示例2: RAISE_ERROR

error_t Mem_Writer::write( const void* p, long s )
{
	long remain = allocated - size_;
	if ( s > remain )
	{
		if ( mode == fixed )
			RAISE_ERROR( "Tried to write more data than expected" );
		
		if ( mode == ignore_excess )
		{
			s = remain;
		}
		else // expanding
		{
			long new_allocated = size_ + s;
			new_allocated += (new_allocated >> 1) + 2048;
			void* p = realloc( data_, new_allocated );
			if ( !p )
				RAISE_ERROR( "Out of memory" );
			data_ = (char*) p;
			allocated = new_allocated;
		}
	}
	
	assert( size_ + s <= allocated );
	memcpy( data_ + size_, p, s );
	size_ += s;
	
	return 0;
}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:30,代码来源:abstract_file.cpp

示例3: _lib7_runtime_export_heap

lib7_val_t   _lib7_runtime_export_heap   (   lib7_state_t*   lib7_state,
                                               lib7_val_t arg
                                           )
{
    /* _lib7_runtime_export_heap : String -> Bool
     *
     * Export the world to the given file and return false (the exported version
     * returns true).
     */

    char	fname[1024];
    FILE	*file;

    strcpy(fname, STR_LIB7toC(arg)); /* XXX BUGGO FIXME no buffer overflow check! */

    fprintf(stderr,"\n");
    fprintf(stderr,"------------------------------------------------------------------------------------------------------\n");
    fprintf(stderr," export-heap.c:_lib7_runtime_export_heap:   Writing file '%s'\n",fname);
    fprintf(stderr,"------------------------------------------------------------------------------------------------------\n");

    if (!(file = fopen(fname, "wb"))) {
      return RAISE_ERROR(lib7_state, "unable to open file for writing");
    }

    lib7_state->lib7_argument = LIB7_true;

    {   int status = ExportHeapImage (lib7_state, file);
        fclose (file);

	if (status == SUCCESS)   return LIB7_false;
	else                     return RAISE_ERROR( lib7_state, "export failed");
    }
}
开发者ID:jes5199,项目名称:mythryl,代码行数:33,代码来源:export-heap.c

示例4: RAISE_ERROR

AnnotationList::RuleBitSet AnnotationList::checkDuplicateDeclarations(
    DeclarationKind declKind,
    const QueryLoc& loc) const
{
  RuleBitSet lCurrAnn;

  // mark and detect duplicates
  for (Annotations::const_iterator ite = theAnnotationList.begin();
       ite != theAnnotationList.end();
       ++ite)
  {
    const store::Item* qname = (*ite)->getQName();
    AnnotationId id = (*ite)->getId();

    // detect duplicate annotations (if we "know" them)
    if (id != AnnotationInternal::zann_end && lCurrAnn.test(id))
    {
      if (declKind == var_decl)
      {
        RAISE_ERROR(err::XQST0116, loc,
        ERROR_PARAMS(ZED(XQST0116_Duplicate), qname->getStringValue()));
      }
      else
      {
        RAISE_ERROR(err::XQST0106, loc,
        ERROR_PARAMS(ZED(XQST0106_Duplicate), qname->getStringValue()));
      }
    }
    lCurrAnn.set(id);
  }
  return lCurrAnn;
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:32,代码来源:annotations.cpp

示例5: get_dst_sockaddr_storage

/* given an host int hte form of C string (e.g. "192.168.1.2" or "localhost"), returns the address */
BOOL get_dst_sockaddr_storage(char *host, SOCKADDR_STORAGE *addrPtr) 
{
	struct addrinfo hints, *res = NULL, *ressave = NULL;
	char serviceName[8] = {0};
	sock_t sock = 0;
	
	if((host == NULL) || (addrPtr == NULL)) 
		return RAISE_ERROR(ERROR_WRONG_ARG, NULL);
	
	bzero(&hints, sizeof(struct addrinfo));
	
	if(NetWorkFamily == IPV6) 
	{
		hints.ai_family = AF_INET6;
		hints.ai_flags = AI_V4MAPPED;
	} 
	else 
	{
		hints.ai_family = AF_INET;
	}
	hints.ai_socktype = SOCK_DGRAM;
	snprintf(serviceName, sizeof(serviceName), "%d", SERVER_PORT); // endianness will be handled by getaddrinfo
	if (getaddrinfo(host, serviceName, &hints, &res) !=0 ) 
	{
		return RAISE_ERROR(ERROR_GENERAL, "Can't resolve hostname");
	}
	
	ressave = res;
	do 
	{
		if((sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) 
		{
			continue;                                  /* try next address */
		}
		
		break;
	} while ((res = res->ai_next) != NULL);
	
	close(sock);
	
	if(res == NULL)   /* error on last iteration */
	{ 
		RAISE_SYS_ERR(ERROR_CREATING);
	}
	
	sock_cpy_addr_port((SOCKADDR *)addrPtr, (res->ai_addr));
	
	freeaddrinfo(ressave);
	
	return TRUE;
}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:52,代码来源:NetWork.c

示例6: _lib7_Ncurses_addch

/* _lib7_Ncurses_addch : Void -> Bool
 *
 */
lib7_val_t

_lib7_Ncurses_addch (lib7_state_t *lib7_state, lib7_val_t arg)
{
#if HAVE_CURSES_H && HAVE_LIBNCURSES
    int ch     = INT32_LIB7toC(arg);    
    int result = addch( ch );
    if (result == ERR)     return RAISE_ERROR(lib7_state, "addch");
    return LIB7_void;
#else
    extern char* no_ncurses_support_in_runtime;
    return RAISE_ERROR(lib7_state, no_ncurses_support_in_runtime);
#endif
}
开发者ID:jes5199,项目名称:mythryl,代码行数:17,代码来源:addch.c

示例7: RAISE_ERROR

void dynamic_context::get_variable(
    ulong varid,
    const store::Item_t& varname,
    const QueryLoc& loc,
    store::Item_t& itemValue,
    store::TempSeq_t& seqValue) const
{
  itemValue = NULL;
  seqValue = NULL;

  if (varid >= theVarValues.size() ||
      theVarValues[varid].theState == VarValue::undeclared)
  {
    zstring varName = static_context::var_name(varname.getp());

    if (varid >= theVarValues.size() ||
        theVarValues[varid].theIsExternalOrLocal ||
        (varid > 0 && varid < MAX_IDVARS_RESERVED))
    {
      RAISE_ERROR(err::XPDY0002, loc,
      ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varName));
    }
    else
    {
      RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName));
    }
  }

  const VarValue& var = theVarValues[varid];

  if (var.theState == VarValue::declared)
  {
    zstring varName = static_context::var_name(varname.getp());

    if (var.theIsExternalOrLocal)
    {
      RAISE_ERROR(err::XPDY0002, loc,
      ERROR_PARAMS(ZED(XPDY0002_VariableHasNoValue_2), varName));
    }
    else
    {
      RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName));
    }
  }

  if (var.theState == VarValue::item)
    itemValue = var.theValue.item;
  else
    seqValue = var.theValue.temp_seq;
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:50,代码来源:dynamic_context.cpp

示例8: put

/*******************************************************************************
  declare updating function
  put($uri as xs:string, $doc as xs:document-node()) as empty-sequence()
********************************************************************************/
bool PutDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;
  store::Item_t lDoc;
  store::Item_t lResolvedUriItem;
  std::unique_ptr<store::PUL> lPul;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document already exists in the store
  if (GENV_STORE.getDocument(lResolvedUriString) != NULL)
  {
    RAISE_ERROR(zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS, loc,
    ERROR_PARAMS(lResolvedUriString));
  }

  // create the pul and add the primitive
  GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString);

  lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());

  consumeNext(lDoc, theChildren[1].getp(), aPlanState);
  lPul->addCreateDocument(&loc, lResolvedUriItem, lDoc);

  result = lPul.release();
  STACK_PUSH(result != NULL, state);

  STACK_END(state);
}
开发者ID:alyst,项目名称:zorba,代码行数:52,代码来源:documents_impl.cpp

示例9: _lib7_Date_mktime

/* _lib7_Date_mktime : (Int, Int, Int, Int, Int, Int, Int, Int, Int)
 *	-> int32::Int
 *
 * This takes a 9-tuple with the fields: tm_sec, tm_min, tm_hour, tm_mday,
 * tm_mon, tm_year, tm_wday, tm_yday, tm_isdst, and returns the corresponding
 * localtime value (in seconds).
 */
lib7_val_t _lib7_Date_mktime (lib7_state_t *lib7_state, lib7_val_t arg)
{
    struct tm	tm;
    time_t	t;

    tm.tm_sec	= REC_SELINT(arg, 0);
    tm.tm_min	= REC_SELINT(arg, 1);
    tm.tm_hour	= REC_SELINT(arg, 2);
    tm.tm_mday	= REC_SELINT(arg, 3);
    tm.tm_mon	= REC_SELINT(arg, 4);
    tm.tm_year	= REC_SELINT(arg, 5);
    /* tm.tm_wday = REC_SELINT(arg, 6); */  /* ignored by mktime */
    /* tm.tm_yday = REC_SELINT(arg, 7); */  /* ignored by mktime */
    tm.tm_isdst	= REC_SELINT(arg, 8);

    t = mktime (&tm);

    if (t < 0) {
        return RAISE_ERROR(lib7_state, "Invalid date");
    }
    else {
	lib7_val_t result;

	INT32_ALLOC(lib7_state, result, t);

	return result;
    }
}
开发者ID:jes5199,项目名称:mythryl,代码行数:35,代码来源:mktime.c

示例10: _lib7_Ncurses_move

Val   _lib7_Ncurses_move   (Task* task,  Val arg)   {    // : (Int, Int) -> Void
    //==================
    //
    #if HAVE_CURSES_H && HAVE_LIBNCURSES
	int y = INT1_LIB7toC( GET_TUPLE_SLOT_AS_INT(arg, 0) );
	int x = INT1_LIB7toC( GET_TUPLE_SLOT_AS_INT(arg, 1) );

	int result = move( y, x );

	if (result == ERR)     return RAISE_ERROR(task, "move");
	return HEAP_VOID;
    #else
	extern char* no_ncurses_support_in_runtime;
	return RAISE_ERROR(task, no_ncurses_support_in_runtime);
    #endif
}
开发者ID:spiralofhope,项目名称:mythryl,代码行数:16,代码来源:move.c

示例11: RAISE_ERROR

char *popen_fgets(char *cmd, char *str, int len)
{
	FILE *fp=NULL; 
	if((cmd == NULL) || (str == NULL))
	{
		RAISE_ERROR(ERROR_WRONG_ARG, NULL);
	   return NULL;
	}
	printf_d("CMD: %s\t", cmd);
	memset(str, 0, len);
	fp = popen(cmd, "r");
	if(fp == NULL)
	{
		printf_d("cmd:%s error!%s\n", cmd, strerror(errno));	   
		APVLog("cmd:%s error!%s\n", cmd, strerror(errno)); 	   
		return NULL;   
	}
	   
	fgets(str, len, fp);	   
	if(str[strlen(str)-1] == '\n')	   
	{		   
	   str[strlen(str)-1] = '\0';	   
	}	   
	pclose(fp);
	printf_d("result:%s\n", str);	   
	return str;
}
开发者ID:tcdog001,项目名称:apv5sdk-v15,代码行数:27,代码来源:global.c

示例12: _ml_P_Process_waitpid

/* _ml_P_Process_waitpid : int * word -> int * int * int
 *
 * Wait for child processes to stop or terminate
 */
ml_val_t _ml_P_Process_waitpid (ml_state_t *msp, ml_val_t arg)
{
    int       pid;
    int       status, how, val;
    ml_val_t  r;

    pid = waitpid(REC_SELINT(arg, 0), &status, REC_SELWORD(arg, 1));
    if (pid < 0)
	return RAISE_SYSERR(msp, pid);

    if (WIFEXITED(status)) {
	how = 0;
	val = WEXITSTATUS(status);
    }
    else if (WIFSIGNALED(status)) {
	how = 1;
	val = WTERMSIG(status);
    }
    else if (WIFSTOPPED(status)) {
	how = 2;
	val = WSTOPSIG(status);
    }
    else
	return RAISE_ERROR(msp, "unknown child status");

    REC_ALLOC3(msp, r, INT_CtoML(pid), INT_CtoML(how), INT_CtoML(val));

    return r;

} /* end of _ml_P_Process_waitpid */
开发者ID:xyproto,项目名称:smlnj,代码行数:34,代码来源:waitpid.c

示例13: kill_node

void kill_node(node n){
	if(n != NULL){
		free(n);
		n= NULL;
	}
	RAISE_ERROR("Could not delete node ");
}
开发者ID:PeterOD,项目名称:ActiveObjectsInLua,代码行数:7,代码来源:in_use.c

示例14: RAISE_ERROR

char *in_id(node n){
	if(n != NULL){
		return n->id;
	}
	RAISE_ERROR("NODE EMPTY -- could not find id");
	return n->id;
}
开发者ID:PeterOD,项目名称:ActiveObjectsInLua,代码行数:7,代码来源:in_use.c

示例15: _lib7_P_Process_osval

/* _lib7_P_Process_osval : String -> int
 *
 * Return the OS-dependent, compile-time constant specified by the string.
 */
lib7_val_t _lib7_P_Process_osval (lib7_state_t *lib7_state, lib7_val_t arg)
{
    name_val_t *result = _lib7_posix_nv_lookup (STR_LIB7toC(arg), values, NUMELMS);

    if (result)   return INT_CtoLib7(result->val);
    else          return RAISE_ERROR(lib7_state, "system constant not defined");
}
开发者ID:jes5199,项目名称:mythryl,代码行数:11,代码来源:osval.c


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