• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PRECOND函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CsfPutAttribute

/* write an attribute to a map (LIBRARY_INTERNAL)
 * MputAttribute writes exactly the number of bytes specified
 * by the size argument starting at the address of argument
 * attr. Which means that you can't simply pass a structure or an
 * array of structures as argument attr, due to the alignment
 * of fields within a structure and internal swapping. You can
 * only pass an array of elementary types (UINT1, REAL4, etc.)
 * or character string.
 * If one wants to refresh an attribute, one should first
 * call MdelAttribute to delete the attribute and then use
 * MputAttribute to write the new value.
 * returns argument id or 0 in case of error.
 *
 * Merrno
 * ATTRDUPL
 * NOACCESS
 * WRITE_ERROR
 */
CSF_ATTR_ID CsfPutAttribute(
	MAP *m,       		/* map handle */
	CSF_ATTR_ID id,               /* attribute identification */
	size_t itemSize,        /* size of each attribute element.
	                         * 1 or sizeof(char) in case of a
	                         * string
	                         */
	size_t nitems,          /* number of attribute elements or
	                         * strlen+1 in case of a variable character
	                         * string field. Don't forget to pad a
	                         * non-variable field with '\0'!
	                         */
	void *attr)       /* buffer containing attribute */
{
	size_t size = nitems * itemSize;

	PRECOND(CsfValidSize(itemSize));
	PRECOND(size > 0);

	if (CsfSeekAttrSpace(m,id,size) == 0)
		goto error;

	if (m->write(attr, itemSize, nitems, m->fp) != nitems)
	{
		M_ERROR(WRITE_ERROR);
		goto error;
	}
	return(id); 		/* succes */
error:	return(0);	/* failure */
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:48,代码来源:putattr.c


示例2: ConvFuncBool

static CSF_CONV_FUNC ConvFuncBool(CSF_CR cr)
{
	PRECOND(CSF_UNIQ_CR_MASK(cr) < 12);
	PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(cr)] != -1);
	
	return boolConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(cr)]];
}
开发者ID:drownedout,项目名称:datamap,代码行数:7,代码来源:ruseas.c


示例3: HasLowerNeighbor

/* Checks a cell on having a lower neighbor.
 * If the height of a neighbor is less than the height of the
 * current cell, then the cell has a lower neighbor.
 * Returns TRUE if this is the case, FALSE otherwise.
 */
static int HasLowerNeighbor(
		const MAP_REAL8 *dem,  		/* dem.map */
		const MAP_REAL8 *points,	/* points.map */
		int rowNr,	     /* row number of checked cell */
		int colNr)	  /* column number of checked cell */
{		
	REAL8 demVal, newDem; /* heights original cell and neighbor */
	REAL8 pntVal; /* if MV, then not a valid lower neighbor */
	int   i;

  	PRECOND(dem->GetGetTest(dem) == GET_MV_TEST);
	PRECOND(dem->Get(&demVal, rowNr, colNr, dem));

	dem->Get(&demVal, rowNr, colNr, dem);

	for(i = 1; i <= NR_LDD_DIR; i++)
	{ /* Check all neighbors for being lower */
		int rNext = RNeighbor(rowNr, i);
		int cNext = CNeighbor(colNr, i);
		if(dem->Get(&newDem, rNext, cNext, dem)&&
		points->Get(&pntVal, rNext, cNext, points) &&
		(demVal > newDem))
			return TRUE;	/* has lower neighbor */
	}
	return FALSE; 			/* no neighbor is lower */
}
开发者ID:pcraster,项目名称:pcraster,代码行数:31,代码来源:drain.c


示例4: PRECOND

/* Initializes a search table.
 * Returns pointer to initialized table.
 *
 */
SEARCH_TABLE *STnew(
 size_t nrFastList, /* nr. of elements in fast list
                          * these are indexed by their position.
                          * if > 0 then specify ReturnId.
                          */
 size_t recSize,  /* size of a record */
 RETURN_ID ReturnId, /* pointer to function that
                          * returns the id, can be NULL 
                          * if nrFastList is 0 or
                          * STinsertOrFind is never used
                          */
 INIT_REC InitRec,    /* pointer to function to
                       * initialize records in the
                       * fastlist or in the InsertOrFind call,
                       * can be NULL if nrFastList is 0 or
                       * STinsertOrFind is never used
                       */
 QSORT_CMP cmp)         /* pointer to compare function */
{
 SEARCH_TABLE *t;
 PRECOND(cmp != NULL);
#ifdef DEBUG
 if (nrFastList > 0)
  PRECOND(nrFastList > 0 && ReturnId != NULL && InitRec != NULL);
#endif 
 t = (SEARCH_TABLE *)ChkMalloc(sizeof(SEARCH_TABLE));
 if(t == NULL)
  return NULL;  /* memory allocation failed */
 t->nrFastList = nrFastList; 
 t->recSize = recSize; 
 /* init slowList here so STfree works in this function */
 t->slowList = NULL;  /* slowlist = empty */
 t->nrSlowList = 0;  /* nr. elements in slow list */
 t->ReturnId = ReturnId;
 t->cmp = cmp;   /* for binary search */
 t->InitRec = InitRec;
 if(nrFastList != 0)
 {
  size_t i;
  char *r;
  t->fastList = ChkMalloc(nrFastList * recSize);
  if(t->fastList == NULL)
  {
   STfree(t);
   return NULL;
  }
  r = t->fastList;
  for ( i = 0 ; i  < nrFastList; i++)
  { 
   InitRec((void *)r,(int)i);
   r += recSize;
  } 
 }
 else
  t->fastList = NULL;
# ifdef DEBUG_DEVELOP
  nrSearchTables++;
# endif
 return t;
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:64,代码来源:table.c


示例5: PRECOND

/* Trim string and replace space by single space.
 * Removes leading and trailing isspace() characters and 
 * substitutes sequences of isspace() chararacters with one  
 * space (that is ' ' not '\t').
 * Returns modified string.
 */
char *LeftRightTabTrim(
	char *str) /* String to be modified */
{
	int i, n;

	PRECOND(str != NULL);

	n = (int)strlen(str);
	if (n == 0)
		return(str);

	(void)LeftRightTrim(str);

	/* substitute sequences of isspace() char with one ' ' */
	for(n=i=0; str[i] != '\0'; i++)
		if (isspace(str[i]))
		{
			PRECOND(n > 0); /* str[0] is not space,
			                 * because leading spaces are removed
					 */
			if (!isspace(str[n-1]))
				str[n++] = ' ';
		}
		else
			str[n++] = str[i];
	str[n] = '\0';

	return(str);

} /* LeftRightTabTrim */
开发者ID:pcraster,项目名称:pcraster,代码行数:36,代码来源:exstring.c


示例6: StrEq

/* wrapper around strcmp()
 * returns 1 if strings are equal, 0 of not
 */
int StrEq(
	const char *s1,  /* first string */
	const char *s2)  /* second string. */
{
	PRECOND(s1 != NULL);
	PRECOND(s2 != NULL);
	return ! strcmp(s1,s2);
} /* StrEq */
开发者ID:pcraster,项目名称:pcraster,代码行数:11,代码来源:exstring.c


示例7: BuildEllipse2

static int BuildEllipse2(REAL8 xmajor_a, REAL8 yminor_b, REAL8 angle)
{
	int i,nrLines,xCeil;
	int lineStart,lineEndIncl;
	REAL8 xIncr,c=cos(angle),s=sin(angle);
	HOR_CUT_LINE *l;
	PRECOND(xmajor_a != 0);
	PRECOND(yminor_b != 0);
	xmajor_a /= Side();
	yminor_b /= Side();

	xCeil = (size_t)ceil(xmajor_a);
	nrLines = (xCeil*2)+1;
	l = (HOR_CUT_LINE *)ChkMalloc(sizeof(HOR_CUT_LINE)*nrLines);
	for(i=0; i < nrLines; i++) {
		/* mark not initialized */
		SET_MV_REAL4(&(l[i].start.f));
	}

	for (xIncr = 0; xIncr < xCeil; xIncr+=1) {
	 REAL8 y = sqrt( fabs(1-(sqr(xIncr)/sqr(xmajor_a)))*sqr(yminor_b));
	 Add2Lines(l,nrLines,xCeil,c,s, xIncr, y);
	 Add2Lines(l,nrLines,xCeil,c,s, xIncr,-y);
	 Add2Lines(l,nrLines,xCeil,c,s,-xIncr, y);
	 Add2Lines(l,nrLines,xCeil,c,s,-xIncr,-y);
	}
	if (0) {
	 REAL8 y;
	 xIncr = xmajor_a;
	 y = sqrt( fabs(1-(sqr(xIncr)/sqr(xmajor_a)))*sqr(yminor_b));
	 Add2Lines(l,nrLines,xCeil,c,s, xIncr, y);
	 Add2Lines(l,nrLines,xCeil,c,s, xIncr,-y);
	 Add2Lines(l,nrLines,xCeil,c,s,-xIncr, y);
	 Add2Lines(l,nrLines,xCeil,c,s,-xIncr,-y);
	}

	for(i=0; i < nrLines; i++) {
		/* mark not initialized */
		if (!IS_MV_REAL4(&(l[i].start.f)))
			break;
	}
	POSTCOND(i < nrLines);
	lineStart = i;
	for(i = nrLines-1; i >=0;i--) {
		/* mark not initialized */
		if (!IS_MV_REAL4(&(l[i].start.f)))
			break;
	}
	POSTCOND(i >= 0);
	lineEndIncl = i;
	
	for (i=lineStart ; i <= lineEndIncl; i++) {
		PRECOND(!IS_MV_REAL4(&(l[i].start.f)));
		l[i].start.i = (int)Rint(l[i].start.f);
		l[i].end.i   = (int)Rint(l[i].end.f);
	}
	return 1;
}
开发者ID:pcraster,项目名称:pcraster,代码行数:58,代码来源:ellipse.c


示例8: CsfSwap

void CsfSwap(void *buf, size_t size, size_t n)
{
	SWAP l[9] = { NULL, Swap1, Swap2, NULL, Swap4,
                      NULL, NULL,  NULL,  Swap8};
        PRECOND(CsfValidSize(size));
	PRECOND(l[size] != NULL);
	
	l[size]((unsigned char *)buf,n);
}
开发者ID:0004c,项目名称:node-gdal,代码行数:9,代码来源:swapio.c


示例9: StrCaseEq

/* compare strings, ignoring the case of the characters
 * returns 1 if strings are equal, 0 of not
 */
int StrCaseEq(
	const char *s1,  /* first string */
	const char *s2)  /* second string. */
{
	PRECOND(s1 != NULL);
	PRECOND(s2 != NULL);

	return StrNCaseEq(s1,s2, MAX(strlen(s1), strlen(s2)) );

} /* StrCaseEq */
开发者ID:pcraster,项目名称:pcraster,代码行数:13,代码来源:exstring.c


示例10: Exchange

static void Exchange(MAP_INT4 *tmp, INT4 i, INT4 j)
{
    INT4 iv = GetINT4(tmp, i);
    INT4 jv = GetINT4(tmp, j);
    PRECOND(i >= 0 && i < (tmp->NrRows(tmp) * tmp->NrCols(tmp)));
    PRECOND(j >= 0 && j < (tmp->NrRows(tmp) * tmp->NrCols(tmp)));
    PRECOND(iv >= 0 && iv < (tmp->NrRows(tmp) * tmp->NrCols(tmp)));
    PRECOND(jv >= 0 && jv < (tmp->NrRows(tmp) * tmp->NrCols(tmp)));
    PutINT4(iv, j, tmp);
    PutINT4(jv, i, tmp);
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:11,代码来源:order.c


示例11: View

/* Determines the visibility for each cell in map.
 * Assumes an UINT1 points map and a spatial REAL8 dem map present. If a
 * cell has a MV in one of the maps, it gets a MV in the output map also.
 * Returns 0 if termination is successful, non-zero otherwise 
 */
int View(
     MAP_UINT1 *out,			/* write-only output map  */ 
     const MAP_REAL8 *dem, 		/* Dig. Elevation map	*/
     const MAP_UINT1 *points) 		/* points map	*/
{
     	UINT1 	pointVal;		/* value in points.map */
     	REAL8 	demVal;			/* value in dem map */
     	int 	r, c , nrRows, nrCols, v = 0;

     	nrRows = dem->NrRows(dem);
     	nrCols = dem->NrCols(dem);

	PRECOND(nrRows == points->NrRows(points));
	PRECOND(nrCols == points->NrCols(points));

	/* Fill out with FALSE, this is the initial value */
	for(r = 0; r < nrRows; r++)
	 for(c = 0; c < nrCols; c++)
	 {
		out->Put((UINT1)0, r, c, out);
	 }

	/* algorithm wants dem->Get() to return FALSE in case of MV */
	dem->SetGetTest(GET_MV_TEST, dem);
	points->SetGetTest(GET_MV_TEST, points);
	out->SetGetTest(GET_MV_TEST, out);

	/* For every view point in the points map */
	AppProgress("\nBusy with viewpoint:\n");
	for (r = 0; r < nrRows; r++)
	 for (c = 0; c < nrCols; c++)
	{
		if(dem->Get(&demVal, r, c, dem)&&
		(points->Get(&pointVal, r, c, points))&&
		(pointVal))
	   	{
	   		v++;
	   		AppProgress("\r%d          ", v);
			if(First(out, r, c, dem, points))
				return 1;
			if(Second(out, r, c, dem, points, nrCols))
				return 1;
			if(Third(out, r, c, dem, points, nrRows))
				return 1;
			if(Fourth(out, r, c, dem, points, nrRows,
								nrCols))
				return 1;
		}
	}
	AppEndRowProgress();
	return 0;		/* successful terminated */ 
}
开发者ID:pcraster,项目名称:pcraster,代码行数:57,代码来源:view.c


示例12: PutINT4

static void PutINT4(INT4 val, INT4 linPos, MAP_INT4 *map)
{
    int nrCols = map->NrCols(map);
    int r = DetRow(nrCols, (int)linPos);
    int c = DetCol(nrCols, (int)linPos);
#ifdef DEBUG
    int nrRows = map->NrRows(map);
    PRECOND(0 <= r && r < nrRows);
    PRECOND(0 <= c && c < nrCols);
#endif

    map->Put(val, r, c, map);
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:13,代码来源:order.c


示例13: FileNameExt

/* check filename extension.
 * FileNameExt checks if fileName ends with a period (.) followed
 * by the given extension. The checks obeys the
 * conventions of filenames on the current platform (case sensitive or not).
 * returns 1 if fileName has that extension, 0 of not.
 */
int FileNameExt(
	const char *fileName,  /* fileName without spaces */
	const char *extension) /* the extension without the period */
{
	const char *p;
	PRECOND(fileName != NULL);
	PRECOND(extension != NULL);
	/* find the position of the extension
	 */
	if ( (p=strrchr(fileName, '.')) == NULL)
		return 0;
	return FileNamesEq(p+1,extension);
}
开发者ID:pcraster,项目名称:pcraster,代码行数:19,代码来源:filestat.c


示例14: STfind

void *STfindOrInsert(
       SEARCH_TABLE *t, /* read-write table */
 const void *r)  /* record to find */
{
 void *c = STfind(t,r);
 PRECOND(t->InitRec != NULL);
 PRECOND(t->ReturnId != NULL);
 if (c != NULL)
  return c;
 c = STinsert(t,r);
 if (c != NULL)
  t->InitRec(c,t->ReturnId(r));
 return c;
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:14,代码来源:table.c


示例15: ConvFunc

static CSF_CONV_FUNC ConvFunc(CSF_CR destType, CSF_CR srcType)
{

	PRECOND(CSF_UNIQ_CR_MASK(destType) < 12);
	PRECOND(CSF_UNIQ_CR_MASK(srcType) < 12);
	PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(srcType)] != -1);
	PRECOND(convTableIndex[CSF_UNIQ_CR_MASK(destType)] != -1);
	/* don't complain on illegal, it can be attached
	 * to a app2file while there's no WRITE_MODE
	 * if it's an error then it's catched in RputSomeCells
	 */
	return 
         ConvTable[(int)convTableIndex[CSF_UNIQ_CR_MASK(srcType)]]
 	          [(int)convTableIndex[CSF_UNIQ_CR_MASK(destType)]];
}
开发者ID:drownedout,项目名称:datamap,代码行数:15,代码来源:ruseas.c


示例16: RgetSomeCells

/* read a stream of cells
 * RgetSomeCells views a raster as one linear stream of
 * cells, with row i+1 placed after row i. 
 * In this stream any sequence can be read by specifying an
 * offset and the number of cells to be read
 * returns the number of cells read, just as fread
 *
 * example
 * .so examples/somecell.tr
 */
size_t RgetSomeCells(
	MAP *map,	/* map handle */
	size_t offset,   /* offset from pixel (row,col) = (0,0) */
	size_t nrCells,  /* number of cells to be read */
	void *buf)/* write-only. Buffer large enough to
                   * hold nrCells cells in the in-file cell representation
                   * or the in-app cell representation.
                   */
{

	CSF_FADDR  readAt;
	size_t cellsRead;
	UINT2  inFileCR = RgetCellRepr(map);

	offset <<= LOG_CELLSIZE(inFileCR);
	readAt = ADDR_DATA + (CSF_FADDR)offset;
	fseek(map->fp, (long)readAt, SEEK_SET);
	cellsRead = map->read(buf, (size_t)CELLSIZE(inFileCR),
	(size_t)nrCells, map->fp);

	PRECOND(map->file2app != NULL);
	map->file2app(nrCells, buf);

	return(cellsRead);
}
开发者ID:0004c,项目名称:node-gdal,代码行数:35,代码来源:_gsomece.c


示例17: owner_modify

static int owner_modify(void)
{
    char *tmp;
    ne_propname pname = { "http://webdav.org/neon/litmus/", "random" };
    ne_proppatch_operation pops[] = { 
	{ NULL, ne_propset, "foobar" },
	{ NULL }
    };
    PRECOND(gotlock);

    ONV(ne_put(i_session, res, i_foo_fd),
	("PUT on locked resource failed: %s", ne_get_error(i_session)));
    
    tmp = ne_concat(i_path, "whocares", NULL);
    ONN("COPY of locked resource", 
	ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR);
    
   if (STATUS(201))
	t_warning("COPY failed with %d not 201", GETSTATUS);
    
    ONN("DELETE of locked resource by owner", 
	ne_delete(i_session, tmp) == NE_ERROR);

    if (STATUS(204)) 
	t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS);
    free(tmp);
    
    ONN("PROPPATCH of locked resource",
	ne_proppatch(i_session, res, pops) == NE_ERROR);
    
    if (STATUS(207))
	t_warning("PROPPATCH failed with %d", GETSTATUS);

    return OK;
}
开发者ID:tolsen,项目名称:limeberry,代码行数:35,代码来源:locks.c


示例18: GetINT4

/* Gets value of INT4 map at location i.
 * returns the INT4 value.
 */
static INT4 GetINT4(const MAP_INT4 *map, /* map to read */
                    INT4 i)              /* location */
{
    INT4 value; /* value to read */
    int nrCols = map->NrCols(map);
    int r = DetRow(nrCols, i);
    int c = DetCol(nrCols, i);
#ifdef DEBUG
    int nrRows = map->NrRows(map);
    PRECOND(0 <= r && r < nrRows);
    PRECOND(0 <= c && c < nrCols);
#endif

    map->Get(&value, r, c, map);
    return value;
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:19,代码来源:order.c


示例19: while

/* insert a record in a sorted array with unique ids
 * InsertSorted copies key to the appropriate place, moving
 * other elements if necessary. Therefore the array must
 * have space for one more element. NOTE that no records,
 * including the key (the new one),
 * must be equal (all unique id's)
 * returns the copied record (part of array)
 */
static void *InsertSorted(
 const void *key,    /* key to be inserted */
       void *base,   /* array of num+1 elements
                      * with element num being vacant
                      */
       size_t num,   /* number of elements initially in
                      * base
                      */
       size_t width, /* sizeof element */
       QSORT_CMP cmp)/* comparisson function */
{
 int x=0; /* num == 0 case */
 int c,l=0;
 int r=num-1;
 if (num == 0)
   goto done;
 do {
      x = (l+r)/2;
      if ( (c = cmp(key, ((char *)base)+(x*width))) < 0)
       r = x-1;
      else
       l = x+1;
       } while (( c != 0) && l <= r );
       POSTCOND(c != 0); /* NOT FOUND */
       if (c > 0)
           x++; /* insertion point is after x */
       PRECOND(x <= (int)num);
       if (x != (int)num) /* no memmove if insertion point is at end */
        /* move part of array after insertion point 1 to the right */
        (void)memmove( (((char *)base)+((x+1)*width)),
          (((char *)base)+(x*width)),
          (num-x)*width );
done:
       return memcpy((((char *)base)+(x*width)), key, width);
}
开发者ID:gaoshuai,项目名称:pcraster,代码行数:43,代码来源:table.c


示例20: LexSkipLines

/* Skip a number of lines in the Lex input
 * LexSkipLines scans the file, set by LexInstall,
 * for a certain number of new line characters. 
 * The end-of-file is also viewed as a new line.
 * returns
 *
 * The number of lines that were skipped, which can be smaller
 * than nrLines if enf-of-file is encountered, or LEX_READ_ERROR 
 * (which is a negative value)
 */
int LexSkipLines(int nrLines) /* > 0, 1 means skip current line only */
{
	int c, i=0;

	PRECOND(nrLines > 0);

	/* ensure that LexGetTokenValue 
         * returns sensible things 
        */
	buf[0] = '\0'; 

	while(1)
	{
read_char:
	 c = fgetc(inFd);
	 switch (c) {
	  case '\n': 
		lineNr++;
		i++;
		if (i == nrLines)
			return i;
	        break;
	  case EOF :
		return feof(inFd) ? i : LEX_READ_ERROR;
	  case 0x1a: /* skip DOS Ctrl-Z at end of file */
	  	goto read_char;
       }
       }
       /*NOTREACHED*/ 
       return LEX_READ_ERROR; /* never reached */
}
开发者ID:pcraster,项目名称:pcraster,代码行数:41,代码来源:simplex.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PRECONDITION函数代码示例发布时间:2022-05-30
下一篇:
C++ PRECACHE_SOUND函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap