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

C++ IS_DIGIT函数代码示例

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

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



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

示例1: CkBracketType

/*****************************************************************************
*   CkBracketType:
*	checks /citation=([1],[3])
*     May be we should check for only single value here like
*	/citation=[digit]
*                                                          -Tatiana 1/28/95
******************************************************************************/
NLM_EXTERN CharPtr CkBracketType(CharPtr str)
{	
	if (str == NULL)
		return "NULL value";
	if (*str == '[') {
		str++;
		if (!IS_DIGIT(*str)) {
			return str;
		} else {
			while (IS_DIGIT(*str)) {
				str++;
			}
			if (*str != ']') {
				return str;
			}
			str++;
			if (*str != '\0') {
				return str;
			}  
			return NULL;
		}
	} else {
		return str;
	}
}
开发者ID:fast-project,项目名称:mpifast,代码行数:32,代码来源:gbfeat.c


示例2: cmp

static int cmp(const void *a, const void *b) {
	char *da = NULL;
	char *db = NULL;
	const char *ca = r_str_trim_ro (a);
	const char *cb = r_str_trim_ro (b);
	if (!a || !b) {
		return (int) (size_t) ((char*) a - (char*) b);
	}
	if (sorted_column > 0) {
		da = strdup (ca);
		db = strdup (cb);
		int colsa = r_str_word_set0 (da);
		int colsb = r_str_word_set0 (db);
		ca = (colsa > sorted_column)? r_str_word_get0 (da, sorted_column): "";
		cb = (colsb > sorted_column)? r_str_word_get0 (db, sorted_column): "";
	}
	if (IS_DIGIT (*ca) && IS_DIGIT (*cb)) {
		ut64 na = r_num_get (NULL, ca);
		ut64 nb = r_num_get (NULL, cb);
		int ret = na > nb;
		free (da);
		free (db);
		return ret;
	}
	if (da && db) {
		int ret = strcmp (ca, cb);
		free (da);
		free (db);
		return ret;
	}
	free (da);
	free (db);
	return strcmp (a, b);
}
开发者ID:tutamuniz,项目名称:radare2,代码行数:34,代码来源:grep.c


示例3: check_number

static bool check_number(const char* str, size_t len)
{
  char num_type = 0;
  int stat = 0;
  for (size_t i = 0; i < len; i++) {
    if ('<' == str[i] || '>' == str[i]) {
      if (0 != stat)
        return false;
      stat = '<';
    } else if ('$' == str[i] || 'O' == str[i] || '%' == str[i]) {
      if ('$' == stat || '0' == stat)
        return false;
      num_type = str[i];
      stat = '$';
    } else if (IS_DIGIT(str[i])) {
      if (('%' == num_type) && ('0' != str[i] && '1' != str[i]))
        return false;
      else if (('O' == num_type) && !IS_DIGIT(str[i]))
        return false;
      stat = '0';
    } else if ('A' <= str[i] && 'F' >= str[i]) {
      if ('$' != num_type)
        return false;
      stat = '0';
    } else {
      break;
    }
  }
  return '0' == stat;    
}
开发者ID:wgtdkp,项目名称:6502-emulator,代码行数:30,代码来源:token.c


示例4: fast_atoi

int fast_atoi(const std::string & src)
{
    if (src.empty())
        return 0;
    const char * p = &src[0];
    const char * end = p + src.size();
    int value = 0;
    int sign = 1;

    while (IS_WHITESPACE(*p) || *p == '0') {
        INCREMENT_PTR();
    }

    switch (*p) {
        case '-':
            sign = -1;
            INCREMENT_PTR();
            break;
        case '+':
            INCREMENT_PTR();
            break;
        default:
            break;
    }

    while (IS_DIGIT(*p)) {
        value = value * 10 + (*p - '0');
        INCREMENT_PTR();
    }

parse_end:
    return value * sign;
}
开发者ID:joaormatos,项目名称:anaconda,代码行数:33,代码来源:stringcommon.cpp


示例5: if

// convert hexadecimal string to unsigned integer
char *hatoui(char *first, char *last, unsigned int *out)
{
	unsigned int result = 0;
	for (; first != last; ++first)
	{
		int digit;
		if (IS_DIGIT(*first))
		{
			digit = *first - '0';
		}
		else if (*first >= 'a' && *first <= 'f')
		{
			digit = *first - 'a' + 10;
		}
		else if (*first >= 'A' && *first <= 'F')
		{
			digit = *first - 'A' + 10;
		}
		else
		{
			break;
		}
		result = 16 * result + digit;
	}
	*out = result;

	return first;
}
开发者ID:Sumith1896,项目名称:precimonious,代码行数:29,代码来源:json.cpp


示例6: is_valid_project_name

static bool is_valid_project_name(const char *name) {
	int i;
	if (r_str_endswith (name, ".zip")) {
		return false;
	}
	for (i = 0; name[i]; i++) {
		switch (name[i]) {
		case '\\': // for w32
		case '.':
		case '_':
		case ':':
		case '-':
			continue;
		}
		if (name[i] >= 'a' && name[i] <= 'z') {
			continue;
		}
		if (name[i] >= 'A' && name[i] <= 'Z') {
			continue;
		}
		if (IS_DIGIT (name[i])) {
			continue;
		}
		return false;
	}
	return true;
}
开发者ID:csarn,项目名称:radare2,代码行数:27,代码来源:project.c


示例7: while

util::number::parse_result util::number::parse(const void* buf, size_t len, uint32_t& n, uint32_t min, uint32_t max)
{
	if (len == 0) {
		return PARSE_ERROR;
	}

	const unsigned char* ptr = (const unsigned char*) buf;
	const unsigned char* end = ptr + len;

	n = 0;

	while (ptr < end) {
		unsigned char c = *ptr++;
		if (!IS_DIGIT(c)) {
			return PARSE_ERROR;
		}

		uint32_t tmp = (n * 10) + (c - '0');

		// Overflow?
		if (tmp < n) {
			return PARSE_ERROR;
		}

		n = tmp;
	}

	if (n < min) {
		return PARSE_UNDERFLOW;
	} else if (n > max) {
		return PARSE_OVERFLOW;
	}

	return PARSE_SUCCEEDED;
}
开发者ID:guidoreina,项目名称:gwebs-plusplus,代码行数:35,代码来源:number.cpp


示例8: CkQualEcnum

/***************************************************************************
*   CkQualEcnum:
*   -- Ec_num has text format,
*      but the text only allow digits, period, and hyphen (-)
*                                                                12-10-93
****************************************************************************/
NLM_EXTERN int CkQualEcnum( GBQualPtr PNTR head_gbqp, GBQualPtr gbqp, 
   GBQualPtr preq,
   Boolean error_msgs, Boolean perform_corrections )
{
   CharPtr  str;
   int retval = GB_FEAT_ERR_NONE;
		

   retval = CkQualText(head_gbqp, gbqp, preq, NULL, FALSE, 
        error_msgs, perform_corrections);
		if (retval == GB_FEAT_ERR_NONE){
   
      str = gbqp->val;
                                                       /* open double quote */
      while (*str != '\0' && (*str == ' ' || *str == '\"'))
          str++;
   
      for (; *str != '\0' && *str != '\"'; str++)
          if (!IS_DIGIT(*str) && *str != '.' && *str != '-') {
            if (error_msgs){ 
               ErrPostEx(SEV_ERROR, ERR_QUALIFIER_BadECnum,
                 "At <%c>(%d) /%s=%s",
                 *str, (int) *str, gbqp->qual,gbqp->val); 
             }
             retval = GB_FEAT_ERR_DROP;
             if (perform_corrections){
                DeleteGBQualFromList(head_gbqp, gbqp, preq);
             }
           break;
      }
   }

   return retval;

} /* CkQualEcnum */
开发者ID:fast-project,项目名称:mpifast,代码行数:41,代码来源:gbfeat.c


示例9: while

number::parse_result_t number::parse_size_t(const char* string, size_t len, size_t& n, size_t min, size_t max)
{
	if (len == 0) {
		return PARSE_ERROR;
	}

	const char* end = string + len;

	n = 0;

	while (string < end) {
		unsigned char c = (unsigned char) *string++;
		if (!IS_DIGIT(c)) {
			return PARSE_ERROR;
		}

		size_t tmp = (n * 10) + (c - '0');

		// Overflow?
		if (tmp < n) {
			return PARSE_ERROR;
		}

		n = tmp;
	}

	if (n < min) {
		return PARSE_UNDERFLOW;
	} else if (n > max) {
		return PARSE_OVERFLOW;
	}

	return PARSE_SUCCEEDED;
}
开发者ID:guidoreina,项目名称:gweb-plusplus,代码行数:34,代码来源:number.cpp


示例10: cin_get_num

static int cin_get_num(RNum *num, RNumCalc *nc, RNumCalcValue *n) {
	double d;
	char str[R_NUMCALC_STRSZ]; // TODO: move into the heap?
	int i = 0;
	char c;
	str[0] = 0;
	while (cin_get (num, nc, &c)) {
		if (c != '_' && c!=':' && c!='.' && !isalnum ((ut8)c)) {
			cin_putback (num, nc, c);
			break;
		}
		if (i < R_NUMCALC_STRSZ) {
			str[i++] = c;
		}
	}
	str[i] = 0;
	*n = Nset (r_num_get (num, str));
	if (IS_DIGIT (*str) && strchr (str, '.')) {
		if (sscanf (str, "%lf", &d) < 1) {
			return 0;
		}
		if (n->n < d) {
			*n = Nsetf (d);
		}
		n->d = d;
	}
	return 1;
}
开发者ID:PankajKataria,项目名称:radare2,代码行数:28,代码来源:calc.c


示例11: strchr

R_API char *r_hex_from_py_array(char *out, const char *code) {
	const char abc[] = "0123456789abcdef";
	if (*code != '[' || !strchr (code, ']')) {
		return NULL;
	}
	code++;
	for (; *code; code++) {
		char *comma = strchr (code, ',');
		if (!comma) {
			comma = strchr (code, ']');
		}
		if (!comma) {
			break;
		}
		char * _word = r_str_ndup (code, comma - code);
		const char *word = _word;
		while (*word == ' ' || *word == '\t' || *word == '\n') {
			word++;
			word = skip_comment_py (word);
		}
		if (IS_DIGIT (*word)) {
			ut8 n = (ut8)r_num_math (NULL, word);
			*out++ = abc[(n >> 4) & 0xf];
			*out++ = abc[n & 0xf];
		}
		free (_word);
		code = comma;
		if (*code == ']') {
			break;
		}
	}
开发者ID:megabug,项目名称:radare2,代码行数:31,代码来源:hex.c


示例12: myatoi

int myatoi(const char *str)
{
	int integer = 0;
	const char * p = str;
	int flag = 1;

	switch (*p) {
	case '+':
		p ++;
		break;
	case '-':
		flag = -1;
		p ++;
		break;
	default:
		break;
	}

	for (; '\0' != *p && IS_DIGIT(*p); p ++) {
		integer *= 10;
		integer += *p - '0';
	}
	
	return flag > 0 ? integer : -integer;
}
开发者ID:oaix101125,项目名称:program,代码行数:25,代码来源:string2int.c


示例13: chxj_url_encode

char *
chxj_url_encode(apr_pool_t *pool, const char *src)
{
  char *dst;
  register char *sp = (char *)src;
  int len;
  register int pos;

  if (! src) return apr_pstrdup(pool, "\0");

  len = strlen(src) * 3 + 1;
  dst = apr_palloc(pool, len);
  memset(dst, 0, len);
  pos = 0;

  while(*sp) {
    if (IS_ALPHA_UPPER(*sp) || IS_ALPHA_LOWER(*sp) || IS_DIGIT(*sp)) {
      dst[pos++] = *sp++;
      continue;
    }
    if (*sp == ' ') {
      dst[pos++] = '+';
      sp++;
      continue;
    }

    dst[pos++] = '%';
    dst[pos++] = TO_HEXSTRING((*sp >> 4) & 0x0f);
    dst[pos++] = TO_HEXSTRING((*sp & 0x0f));
    sp++;
  }
  return dst;
}
开发者ID:unpush,项目名称:mod_chxj,代码行数:33,代码来源:chxj_url_encode.c


示例14: xmlPatScanNCName

static xmlChar *
xmlPatScanNCName(xmlPatParserContextPtr ctxt) {
    const xmlChar *q, *cur;
    xmlChar *ret = NULL;
    int val, len;

    SKIP_BLANKS;

    cur = q = CUR_PTR;
    val = xmlStringCurrentChar(NULL, cur, &len);
    if (!IS_LETTER(val) && (val != '_'))
	return(NULL);

    while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
           (val == '.') || (val == '-') ||
	   (val == '_') ||
	   (IS_COMBINING(val)) ||
	   (IS_EXTENDER(val))) {
	cur += len;
	val = xmlStringCurrentChar(NULL, cur, &len);
    }
    ret = xmlStrndup(q, cur - q);
    CUR_PTR = cur;
    return(ret);
}
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:25,代码来源:pattern.c


示例15: getHostAddress

/*---------------------------------------------------------------------------*/
int getHostAddress (struct sockaddr_in *sin, const char *hostName, short port)
{
	struct hostent * hostent;

	sin->sin_family = AF_INET;
	sin->sin_port   = htons(port);
	
	// first try the name as a numbered IP address 
	if (IS_DIGIT(hostName[0]))
	{
		char testStr[16];

		webc_str_to_ip((unsigned char *) &sin->sin_addr, hostName);
		
		// do a check to make sure we translated an IP address
		webc_ip_to_str(testStr, (unsigned char *) &sin->sin_addr);
		if (!strcmp(hostName, testStr))
		{
			// if we go from string to ip addr and back, without
			//  changing the host name, this is success.
			return(0);
		}
	}
	
	// try looking up the name via DNS
	if ((hostent = gethostbyname(hostName)))
	{
		memcpy((unsigned char *) &sin->sin_addr, (unsigned char *) hostent->h_addr, 4);
		return(0);
	}
	
	return (-1);
}
开发者ID:maojxsir,项目名称:upnp,代码行数:34,代码来源:httptest.c


示例16: XSkip_digitBlock

/*
 * [RFC5234]
 * DIGIT =  %x30-39
 *               ; 0-9
 */
int
XSkip_digitBlock(const char *head, const char *tail, const char **nextp)
{
    const char *p;
    for (p = head; p < tail && IS_DIGIT(*p); ++p);
    *nextp = p;
    return *nextp - head;
}   // end function : XSkip_digitBlock
开发者ID:mrmt,项目名称:enma,代码行数:13,代码来源:xskip.c


示例17: CkLabelType

/*****************************************************************************
*   CkLabelType:
*	checks /label=,feature_label> or /label=<base_range>
*                                                          -Tatiana 1/28/95
******************************************************************************/
NLM_EXTERN CharPtr CkLabelType(CharPtr str)
{
	Boolean range = TRUE, label = TRUE;
	CharPtr		bptr;
	
	if (IS_DIGIT(*str)) {
		for (; IS_DIGIT(*str); str++)
			continue;
		if (*str == '.' && *(str+1) == '.') {
			str += 2;
			if (!IS_DIGIT(*str)) {
				range = FALSE;
			} else {
				while (IS_DIGIT(*str)) {
					str++;
				}
			}
			if (*str != '\0') {
				range = FALSE;
			}
		} else {
			range = FALSE;
		}
		
	} 
	if (!range) {
		bptr = str;
		for (;  *str != '\0' && !IS_ALPHA(*str); str++)
			continue;
		if (*str == '\0') {
			label = FALSE;    /* must be at least one letter */
		}
		for (str = bptr; *str != '\0' && IS_ALPHA(*str) || IS_DIGIT(*str) 
			|| *str == '-' || *str == '_' || *str == '\'' || *str == '*';
			str++)
			continue;
		if (*str != '\0') {
			label = FALSE;
		}
	}
	if (range || label) {
		return NULL;
	} else {
		return str;
	}
}
开发者ID:fast-project,项目名称:mpifast,代码行数:51,代码来源:gbfeat.c


示例18: s_StringToUint8

static Nlm_Uint8 s_StringToUint8(const char *str, const char **endptr, int *sgn)
{
    int sign = 0;  /* actual sign */
    Nlm_Uint8 limdiv, limoff, result;
    const char *s, *save;
    char c;

    /* assume error */
    *endptr = 0;
    if (!str)
        return 0;

    s = str;
    while (IS_WHITESP(*s))
        s++;
    /* empty string - error */
    if (*s == '\0')
        return 0;

    if (*sgn == 1) {
        if (*s == '-') {
            sign = 1;
            s++;
        } else if (*s == '+') {
            s++;
        }        
    }
    save = s;

    limdiv = UINT8_MAX / 10;
    limoff = UINT8_MAX % 10;
    result = 0;
    
    for (c = *s; c; c = *++s) {
        if (!IS_DIGIT(c)) {
            break;
        }
        c -= '0';
        if (result > limdiv || (result == limdiv && c > limoff)) {
            /* overflow */
            return 0;
        }
        result *= 10;
        result += c;
    }

    /* there was no conversion - error */
    if (save == s)
        return 0;

    *sgn = sign;
    *endptr = s;
    return result;
}
开发者ID:fbtestrepo,项目名称:hw,代码行数:54,代码来源:ncbistr.c


示例19: r_hex_to_byte

/* int c; ret = hex_to_byte(&c, 'c'); */
R_API int r_hex_to_byte(ut8 *val, ut8 c) {
	if (IS_DIGIT(c)) {
		*val = (ut8)(*val) * 16 + (c - '0');
	} else if (c >= 'A' && c <= 'F') {
		*val = (ut8)(*val) * 16 + (c - 'A' + 10);
	} else if (c >= 'a' && c <= 'f') {
		*val = (ut8)(*val) * 16 + (c - 'a' + 10);
	} else {
		return 1;
	}
	return 0;
}
开发者ID:megabug,项目名称:radare2,代码行数:13,代码来源:hex.c


示例20: is_nbr

static t_bool	is_nbr(const char *str)
{
  int		idx;

  if (!(str))
    return (FALSE);
  str += (*str == SIGN_CHAR) ? (1) : (0);
  idx = 0;
  while (str[idx] && IS_DIGIT(str[idx]))
    ++idx;
  return (((idx == NULL_VALUE) || (str[idx])) ? (FALSE) : (TRUE));
}
开发者ID:rotarui,项目名称:42sh,代码行数:12,代码来源:my_getnbr.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IS_DIR_SEPARATOR函数代码示例发布时间:2022-05-30
下一篇:
C++ IS_DEBUG_OSPF函数代码示例发布时间: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