本文整理汇总了C++中IsInt函数的典型用法代码示例。如果您正苦于以下问题:C++ IsInt函数的具体用法?C++ IsInt怎么用?C++ IsInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mathWrapInt
int mathWrapInt(struct VMGlobals *g, int numArgsPushed)
{
PyrSlot *a, *b, *c;
int err;
a = g->sp - 2;
b = g->sp - 1;
c = g->sp;
if (IsSym(b)) {
*a = *b;
} else if (IsSym(c)) {
*a = *c;
} else if (IsInt(b) && IsInt(c)) {
SetRaw(a, sc_mod((int)(slotRawInt(a) - slotRawInt(b)), (int)(slotRawInt(c) - slotRawInt(b) + 1)) + slotRawInt(b));
} else {
double x, lo, hi;
x = slotRawInt(a);
err = slotDoubleVal(b, &lo);
if (err) return err;
err = slotDoubleVal(c, &hi);
if (err) return err;
SetFloat(a, sc_mod(x - lo, hi - lo) + lo);
}
return errNone;
}
示例2: ASSERT_VALID
bool CTag::WriteTagToFile(CFileDataIO* file, EUtf8Str eStrEncode) const
{
ASSERT_VALID(this);
// don't write tags of unknown types, we wouldn't be able to read them in again
// and the met file would be corrupted
if (IsStr() || IsInt() || IsFloat() || IsBlob() || IsInt64())
{
file->WriteUInt8(m_uType);
if (m_pszName)
{
UINT taglen = strlen(m_pszName);
file->WriteUInt16((uint16)taglen);
file->Write(m_pszName, taglen);
}
else
{
file->WriteUInt16(1);
file->WriteUInt8(m_uName);
}
if (IsStr())
{
file->WriteString(GetStr(), eStrEncode);
}
else if (IsInt())
{
file->WriteUInt32((uint32)m_uVal);
}
else if (IsInt64(false))
{
file->WriteUInt64(m_uVal);
}
else if (IsFloat())
{
file->Write(&m_fVal, 4);
}
else if (IsBlob())
{
// NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
file->WriteUInt32(m_nBlobSize);
file->Write(m_pData, m_nBlobSize);
}
//TODO: Support more tag types
else
{
TRACE("%s; Unknown tag: type=0x%02X\n", __FUNCTION__, m_uType);
ASSERT(0);
return false;
}
return true;
}
else
{
TRACE("%s; Ignored tag with unknown type=0x%02X\n", __FUNCTION__, m_uType);
ASSERT(0);
return false;
}
}
示例3: mathFoldInt
int mathFoldInt(struct VMGlobals *g, int numArgsPushed)
{
PyrSlot *a, *b, *c;
int err;
a = g->sp - 2;
b = g->sp - 1;
c = g->sp;
if (IsSym(b)) {
*a = *b;
} else if (IsSym(c)) {
*a = *c;
} else if (IsInt(b) && IsInt(c)) {
SetRaw(a, sc_fold(slotRawInt(a), slotRawInt(b), slotRawInt(c)));
} else {
double x, lo, hi;
x = slotRawInt(a);
err = slotDoubleVal(b, &lo);
if (err) return err;
err = slotDoubleVal(c, &hi);
if (err) return err;
SetFloat(a, sc_fold(x, lo, hi));
}
return errNone;
}
示例4: ReadPhylip
/* Function: ReadPhylip()
* Date: SRE, Fri Jun 18 12:59:37 1999 [Sanger Centre]
*
* Purpose: Parse an alignment from an open Phylip format
* alignment file. Phylip is a single-alignment format.
* Return the alignment, or NULL if we have no data.
*
* Args: afp - open alignment file
*
* Returns: MSA * - an alignment object
* Caller responsible for an MSAFree()
* NULL if no more alignments
*/
MSA *
ReadPhylip(MSAFILE *afp)
{
MSA *msa;
char *s, *s1, *s2;
char name[11]; /* seq name max len = 10 char */
int nseq, alen;
int idx; /* index of current sequence */
int slen;
int nblock;
if (feof(afp->f)) return NULL;
/* Skip until we see a nonblank line; it's the header,
* containing nseq/alen
*/
nseq = 0; alen = 0;
while ((s = MSAFileGetLine(afp)) != NULL)
{
if ((s1 = sre_strtok(&s, WHITESPACE, NULL)) == NULL) continue;
if ((s2 = sre_strtok(&s, WHITESPACE, NULL)) == NULL)
Die("Failed to parse nseq/alen from first line of PHYLIP file %s\n", afp->fname);
if (! IsInt(s1) || ! IsInt(s2))
Die("nseq and/or alen not an integer in first line of PHYLIP file %s\n", afp->fname);
nseq = atoi(s1);
alen = atoi(s2);
break;
}
msa = MSAAlloc(nseq, 0);
idx = 0;
nblock = 0;
while ((s = MSAFileGetLine(afp)) != NULL)
{
/* ignore blank lines. nonblank lines start w/ nonblank char */
if (isspace(*s)) continue;
/* First block has seq names */
if (nblock == 0) {
strncpy(name, s, 10);
name[10] = '\0';
GKIStoreKey(msa->index, name);
msa->sqname[idx] = sre_strdup(name, -1);
s += 10;
}
/* be careful of trailing whitespace on lines */
if ((s1 = sre_strtok(&s, WHITESPACE, &slen)) == NULL)
Die("Failed to parse sequence at line %d of PHYLIP file %s\n",
afp->linenumber, afp->fname);
msa->sqlen[idx] = sre_strcat(&(msa->aseq[idx]), msa->sqlen[idx], s1, slen);
idx++;
if (idx == nseq) { idx = 0; nblock++; }
}
msa->nseq = nseq;
MSAVerifyParse(msa); /* verifies; sets alen, wgt; frees sqlen[] */
return msa;
}
示例5: GetColorFromInts
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
bool DeveloperConsoleArguments::GetColorFromInts( Rgba& color )
{
std::string string = "";
if (PeekString( string ))
{
if (IsInt( string ))
{
color.r = (char)strtol( string.c_str(), nullptr, 10 );
m_currentIndex++;
}
else
return false;
}
if (PeekString( string ))
{
if (IsInt( string ))
{
color.g = (char)strtol( string.c_str(), nullptr, 10 );
m_currentIndex++;
}
else
return false;
}
if (PeekString( string ))
{
if (IsInt( string ))
{
color.b = (char)strtol( string.c_str(), nullptr, 10 );
m_currentIndex++;
}
else
return false;
}
if (PeekString( string ))
{
if (IsInt( string ))
{
color.a = (char)strtol( string.c_str(), nullptr, 10 );
m_currentIndex++;
return true;
}
else
return false;
}
return false;
}
示例6: PriorityQueueAdd
void PriorityQueueAdd(struct VMGlobals *g, PyrObject* queueobj, PyrSlot* item, double time)
{
PyrObject *schedq, *newschedq;
int size, maxsize;
PyrSlot *schedqSlot = queueobj->slots;
if (!IsObj(schedqSlot)) {
size = 32;
schedq = newPyrArray(g->gc, size, 0, true);
schedq->size = 1;
SetInt(schedq->slots + 0, 0); // stability count
SetObject(schedqSlot, schedq);
g->gc->GCWriteNew(queueobj, schedq); // we know schedq is white so we can use GCWriteNew
} else {
schedq = slotRawObject(schedqSlot);
maxsize = ARRAYMAXINDEXSIZE(schedq);
size = schedq->size;
if (size+3 > maxsize) {
newschedq = newPyrArray(g->gc, maxsize*2, 0, true);
newschedq->size = size;
slotCopy(newschedq->slots, schedq->slots, size);
assert(IsInt(newschedq->slots));
SetObject(schedqSlot, newschedq);
g->gc->GCWriteNew(queueobj, newschedq); // we know newschedq is white so we can use GCWriteNew
schedq = newschedq;
}
}
addheap(g, schedq, time, item);
}
示例7: SetValue
void Table::SetValue(const Value &key, const Value &value)
{
// Try array part
if (key.type_ == ValueT_Number && IsInt(key.num_))
{
if (SetArrayValue(static_cast<std::size_t>(key.num_), value))
return ;
}
// Hash part
if (!hash_)
{
// If value is nil and hash part is not existed, then do nothing
if (value.IsNil())
return ;
hash_.reset(new Hash);
}
auto it = hash_->find(key);
if (it != hash_->end())
{
// If value is nil, then just erase the element
if (value.IsNil())
hash_->erase(it);
else
it->second = value;
}
else
{
// If key is not existed and value is not nil, then insert it
if (!value.IsNil())
hash_->insert(std::make_pair(key, value));
}
}
示例8: prSetControlBusValues
int prSetControlBusValues(VMGlobals *g, int numArgsPushed)
{
PyrSlot *a = g->sp - 2;
PyrSlot *b = g->sp - 1;
PyrSlot *c = g->sp;
assert(IsObj(a));
PyrObject * self = slotRawObject(a);
int ptrIndex = 0;
PyrSlot * ptrSlot = self->slots + ptrIndex;
if (NotPtr(ptrSlot))
return errFailed;
if (!IsInt(b))
return errFailed;
int busIndex = slotRawInt(b);
if (!IsObj(c))
return errFailed;
PyrObject * values = slotRawObject(c);
server_shared_memory_client * client = (server_shared_memory_client*)slotRawPtr(ptrSlot);
float * control_busses = client->get_control_busses() + busIndex;
for (int i = 0; i != values->size; ++i) {
float value;
int error = slotFloatVal(values->slots + i, &value);
if (error != errNone)
return error;
control_busses[i] = value;
}
return errNone;
}
示例9: prSetControlBusValue
int prSetControlBusValue(VMGlobals *g, int numArgsPushed)
{
PyrSlot *a = g->sp - 2;
PyrSlot *b = g->sp - 1;
PyrSlot *c = g->sp;
assert(IsObj(a));
PyrObject * self = slotRawObject(a);
int ptrIndex = 0;
PyrSlot * ptrSlot = self->slots + ptrIndex;
if (NotPtr(ptrSlot))
return errFailed;
if (!IsInt(b))
return errFailed;
int busIndex = slotRawInt(b);
if (NotPtr(ptrSlot))
return errFailed;
float value;
int error = slotFloatVal(c, &value);
if (error != errNone)
return error;
server_shared_memory_client * client = (server_shared_memory_client*)slotRawPtr(ptrSlot);
client->get_control_busses()[busIndex] = value;
return errNone;
}
示例10: prArray_OSCBytes
int prArray_OSCBytes(VMGlobals *g, int numArgsPushed)
{
PyrSlot* a = g->sp;
PyrObject *array = a->uo;
PyrSlot* args = array->slots;
int numargs = array->size;
if (numargs < 1) return errFailed;
big_scpacket packet;
if (IsFloat(args) || IsNil(args) || IsInt(args)) {
makeSynthBundle(&packet, args, numargs, false);
} else if (IsSym(args) || isKindOfSlot(args, class_string)) {
makeSynthMsgWithTags(&packet, args, numargs);
} else {
return errWrongType;
}
int size = packet.size();
PyrInt8Array* obj = newPyrInt8Array(g->gc, size, 0, true);
obj->size = size;
memcpy(obj->b, packet.data(), size);
SetObject(a, (PyrObject*)obj);
//for (int i=0; i<packet.size()/4; i++) post("%d %08X\n", i, packet.buf[i]);
return errNone;
}
示例11: markChildren
void markChildren(word* p, int s[]){
if(Color(p[0]) == White){
p[0] = Paint(p[0], Black);
for(int i = 1; i <= Length(p[0]); i++){
if(!IsInt(p[i]) && p[i] != 0) markChildren((word*) p[i], s);
}
}
}
示例12: ParseInt
bool BaseParser::ParseInt(const std::string& value, int& ret)
{
if(IsInt(value) == false)
{
return false;
}
ret = strtol(value.c_str(), nullptr, 10);
return true;
}
示例13: GetStr
/////////////////////////////////////////////////
// Prolog-Value
TStr TPlVal::GetStr(TPlBs* PlBs) const {
TChA ChA;
if (IsInt()){ChA+=TInt::GetStr(GetInt());}
else if (IsFlt()){ChA+=TFlt::GetStr(GetFlt());}
else if (IsAtom()){ChA+=PlBs->GetAtomQStr(GetAtomId());}
else if (IsTup()){PPlTup Tup=PlBs->GetTup(GetTupId()); ChA+=Tup->GetStr(PlBs);}
else {Fail;}
return ChA;
}
示例14: markPhase
void markPhase(int s[], int sp) {
printf("marking ...\n");
while(sp > 0){
if(!IsInt(s[sp]) && s[sp] != 0) {
markChildren((word*) s[sp],s);
}
sp--;
}
}
示例15: markPhase
//Mark all headers referenced from the stack
void markPhase(int s[], int sp) {
printf("marking ...\n");
int i;
for(i = 0; i<sp; i++){
if(!IsInt(s[i]) && s[i] != 0){
mark((word *)s[i]);
}
}
}