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


C++ PRECOND函数代码示例

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


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


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