Example #1
0
//
// Find the first occurrence of <str> in the string
//
int	STR_String::Find(rcSTR_String str, int pos) const
{
	assertd(pos >= 0);
	assertd(Len==0 || pos<Len);
	assertd(pData != NULL);
	char *find_pos = strstr(pData+pos, str.ReadPtr());
	return (find_pos) ? (find_pos-pData) : -1;
}
Example #2
0
//
// Find the first occurrence of any character in character set <set> in the string
//
int STR_String::FindOneOf(const char *set, int pos) const
{
	assertd(pos >= 0);
	assertd(this->m_len == 0 || pos < this->m_len);
	assertd(this->m_data != NULL);
	char *find_pos = strpbrk(this->m_data + pos, set);
	return (find_pos) ? (find_pos - this->m_data) : -1;
}
Example #3
0
//
// Find the first occurrence of <str> in the string
//
int STR_String::Find(const char *str, int pos) const
{
	assertd(pos >= 0);
	assertd(this->m_len == 0 || pos < this->m_len);
	assertd(this->m_data != NULL);
	char *find_pos = strstr(this->m_data + pos, str);
	return (find_pos) ? (find_pos - this->m_data) : -1;
}
Example #4
0
//
// Find the first orccurence of <c> in the string
//
int STR_String::Find(char c, int pos) const
{
	assertd(pos >= 0);
	assertd(Len==0 || pos<Len);
	assertd(pData != NULL);
	char *find_pos = strchr(pData+pos, c);
	return (find_pos) ? (find_pos-pData) : -1;
}
Example #5
0
//
// Construct a string from the first number of characters in another string
//
STR_String::STR_String(rcSTR_String str, int len) :
	pData(new char [len+8]),
	Len(len),
	Max(len+8)
{
	assertd(pData != NULL);
	assertd(str.pData != NULL);
	memcpy(pData, str.pData, str.Length());
	pData[str.Length()] = 0;
}
Example #6
0
//
// Set the string's conents to a copy of <src> with length <len>
//
rcSTR_String STR_String::Copy(const char *src, int len)
{
	assertd(len>=0);
	assertd(src);
	assertd(pData != NULL);

	AllocBuffer(len, false);
	Len = len;
	memcpy(pData, src, len);
	pData[Len] = 0;

	return *this;
}
void Cycle::multiplyByTranspositions(shared_ptr<list<Transposition>> transpositions,
    bool isLeftMultiplication, vector<shared_ptr<Cycle>>* output) const
{
    unordered_set<word> visitedElements;
    unordered_set<word>::const_iterator end = visitedElements.cend();
    shared_ptr<Cycle> nextCycle(new Cycle());

    uint elementCount = length();
    for(uint index = 0; index < elementCount; ++index)
    {
        word x = elements[index];
        if(visitedElements.find(x) == end)
        {
            while(!nextCycle->isFinal())
            {
                word y = x;
                if(isLeftMultiplication)
                {
                    y = getOutput(y, transpositions);
                    y = getOutput(y);
                }
                else
                {
                    y = getOutput(y);
                    y = getOutput(y, transpositions);
                }

                if(nextCycle->isEmpty())
                    nextCycle->append(x);

                nextCycle->append(y);

                visitedElements.insert(x);
                x = y;
            }

            // skip fixed point
            uint cycleLength = nextCycle->length();
            if(cycleLength > 1)
                output->push_back(nextCycle);

            nextCycle = shared_ptr<Cycle>(new Cycle());
        }
    }

    assertd(visitedElements.size() == elementCount,
        string("Cycle::multiplyByTranspositions() failed because not all elements processed"));

    assertd(!nextCycle->length(),
        string("Cycle::multiplyByTranspositions() failed because of last cycle"));
}
Example #8
0
//
// Concate a number of bytes to the current string
//
rcSTR_String STR_String::Concat(const char *data, int len)
{
	assertd(this->m_len >= 0);
	assertd(len >= 0);
	assertd(data);
	assertd(this->m_data != NULL);

	AllocBuffer(this->m_len + len, true);
	memcpy(this->m_data + this->m_len, data, len);
	this->m_len += len;
	this->m_data[this->m_len] = 0;

	return *this;
}
Example #9
0
//
// Format string (as does sprintf)
//
STR_String& STR_String::Format(const char *fmt, ...)
{
	AllocBuffer(2048, false);

	assertd(this->m_data != NULL);
	// Expand arguments and format to string
	va_list args;
	va_start(args, fmt);
	this->m_len = vsprintf(this->m_data, fmt, args);
	assertd(this->m_len <= 2048);
	va_end(args);

	return *this;
}
Example #10
0
//
// Format string (as does sprintf)
//
STR_String& STR_String::FormatAdd(const char *fmt, ...)
{
	AllocBuffer(2048, false);

	assertd(pData != NULL);
	// Expand arguments and format to string
	va_list args;
	va_start(args, fmt);
	Len += vsprintf(pData+Len, fmt, args);
	assertd(Len <= 2048);
	va_end(args);

	return *this;
}
Example #11
0
//
// Concate a number of bytes to the current string
//
rcSTR_String STR_String::Concat(const char *data, int len)
{
	assertd(Len>=0);
	assertd(len>=0);
	assertd(data);
	assertd(pData != NULL);

	AllocBuffer(Len+len, true);
	memcpy(pData+Len, data, len);
	Len+=len;
	pData[Len] = 0;

	return *this;
}
Example #12
0
/*
bool COperator2Expr::IsInside(float x, float y, float z,bool bBorderInclude)
{
	bool inside;
	inside = false;
	
	switch (m_op) 
	{
	case VALUE_ADD_OPERATOR: {
	//	inside = first || second; // optimized with early out if first is inside
		// todo: calculate smallest leaf first ! is much faster...
			
		bool second;//first ;//,second;
		
		//first = m_lhs->IsInside(x,y,z) ;
		second = m_rhs->IsInside(x,y,z,bBorderInclude) ;
		if (second)
			return true; //early out
	
	//	second = m_rhs->IsInside(x,y,z) ;

		return m_lhs->IsInside(x,y,z,bBorderInclude) ;
			
		break;
							 }
		
	case VALUE_SUB_OPERATOR: {
		//inside = first && !second; // optimized with early out
		// todo: same as with add_operator: calc smallest leaf first

		bool second;//first ;//,second;
		//first = m_lhs->IsInside(x,y,z) ;
		second = m_rhs->IsInside(x,y,z,bBorderInclude);
		if (second)
			return false;

		// second space get subtracted -> negate!
		//second = m_rhs->IsInside(x,y,z);

		return (m_lhs->IsInside(x,y,z,bBorderInclude));

		
		break;
							 }
	default:{
		assert(false);
		// not yet implemented, only add or sub csg operations
			}
	}
	
	return inside;	
}



bool COperator2Expr::IsRightInside(float x, float y, float z,bool bBorderInclude) {
	
	return m_rhs->IsInside(x,y,z,bBorderInclude) ;
	
}

bool COperator2Expr::IsLeftInside(float x, float y, float z,bool bBorderInclude) {
	return m_lhs->IsInside(x,y,z,bBorderInclude);
}
*/
bool COperator2Expr::NeedsRecalculated() {
	// added some lines, just for debugging purposes, it could be a one-liner :)
	//bool modleft
	//bool modright;
	assertd(m_lhs);
	assertd(m_rhs);

	//modright = m_rhs->NeedsRecalculated();
	if (m_rhs->NeedsRecalculated()) // early out
		return true;
	return m_lhs->NeedsRecalculated();
	//modleft = m_lhs->NeedsRecalculated();
	//return (modleft || modright);
	
}
Example #13
0
int mmap_thread() {
  atomicBegin();
    assume(sem == 1);
    sem = 0;
  atomicEnd();
  assert(vm_consistent == 1);
  noReorderBegin();
    assertd(((want_sem == 0) | (mtx == 0)) | (sem != 0));
    want_mtx = 1;
    atomicBegin();
      assume(mtx == 0);
      mtx = 1;
      want_mtx = 0;
    atomicEnd();
    assert(state != 3);
    state = 3;
    state = 1;
    state = 3;
    state = 2;
    mtx = 0;
  noReorderEnd();
  vm_consistent = 0;
  vm_consistent = 1;
  sem = 1;
}
Example #14
0
//
// Trim whitespaces from the right side of the string
//
STR_String& STR_String::TrimRight()
{
	assertd(this->m_data != NULL);
	while (this->m_len && isSpace(this->m_data[this->m_len - 1])) this->m_len--;
	this->m_data[this->m_len] = 0;
	return *this;
}
Example #15
0
int ioctl_thread() {
  int old_state;
  old_state = state;
  state = 3;
  state = old_state;
  atomicBegin();
    assume(mtx == 0);
    mtx = 1;
  atomicEnd();
  assertd(state != 3);
  if (nondet == 0) {
  } else {
    noReorderBegin();
      assert(((want_mtx == 0) | (sem == 1)) | (mtx == 0));
      want_sem = 2;
      atomicBegin();
        assume(sem == 1);
        sem = 0;
        want_sem = 0;
      atomicEnd();
      assert(vm_consistent);
      sem = 1;
    noReorderEnd();
  }
  mtx = 0;
}
Example #16
0
//
// Trim characters from the character set <set> from the right side of the string
//
STR_String& STR_String::TrimRight(char *set)
{
	assertd(this->m_data != NULL);
	while (this->m_len && strchr(set, this->m_data[this->m_len - 1])) this->m_len--;
	this->m_data[this->m_len] = 0;
	return *this;
}
void Cycle::append(word element)
{
    assertd(!finalized, string("Failed to append element to finalized cycle"));

    auto pos = find(elements.cbegin(), elements.cend(), element);
    if(pos == elements.cend())
        elements.push_back(element);
    else if (pos == elements.cbegin())
        finalize();
    else
    {
        ostringstream stream;
        stream << "Failed to append " << element << " to cycle";
        assertd(false, stream.str());
    }
}
Example #18
0
//
// Create a string with a double value
//
STR_String::STR_String(double val) :
	m_data(new char[STR_STRING_SIZE_DEFAULT_WORD]),
	m_max(STR_STRING_SIZE_DEFAULT_WORD)
{
	assertd(this->m_data != NULL);
	this->m_len = sprintf(this->m_data, "%g", val);
}
Example #19
0
//
// Trim characters from the character set <set> from the right side of the string
//
STR_String&	STR_String::TrimRight(char *set)
{
	assertd(pData != NULL);
	while (Len && strchr(set, pData[Len-1])) Len--;
	pData[Len]=0;
	return *this;
}
Example #20
0
//
// Trim whitespaces from the right side of the string
//
STR_String&	STR_String::TrimRight()
{
	assertd(pData != NULL);
	while (Len && isSpace(pData[Len-1])) Len--;
	pData[Len]=0;
	return *this;
}
Example #21
0
//
// Create a string with a double value
//
STR_String::STR_String(double val) :
	pData(new char [32]),
	Max(32)
{
	assertd(pData != NULL);
	Len=sprintf(pData, "%g", val);
}
Example #22
0
bool COperator1Expr::MergeExpression(CExpression *otherexpr)
{
	if (m_lhs)
		return m_lhs->MergeExpression(otherexpr);
	
	assertd(false); // should not get here, expression is not compatible for merge
	return false;
}
Example #23
0
int thread2() {
  b = 1;
  noReorderBegin();
    assertd(x == 1);
    a = 1;
  noReorderEnd();
  assume(y == 1);
}
Example #24
0
bool PTXPointReader::loadChunk(fstream *stream, long currentChunk, double tr[16]) {
    vector<double> split;

    // The first 5 lines should have respectively 1, 3, 3, 3, 3 numbers each.
    if (!assertd(*stream, 1) || !assertd(*stream, 3) || !assertd(*stream, 3) || !assertd(*stream, 3) || !assertd(*stream, 3))
        return false;

    getlined(*stream, split);
    if (4 != split.size()) {
        return false;
    };
    tr[0] = split[0];
    tr[1] = split[1];
    tr[2] = split[2];
    tr[3] = split[3];

    getlined(*stream, split);
    if (4 != split.size()) {
        return false;
    };
    tr[4] = split[0];
    tr[5] = split[1];
    tr[6] = split[2];
    tr[7] = split[3];

    getlined(*stream, split);
    if (4 != split.size()) {
        return false;
    };
    tr[8] = split[0];
    tr[9] = split[1];
    tr[10] = split[2];
    tr[11] = split[3];

    getlined(*stream, split);
    if (4 != split.size()) {
        return false;
    };
    tr[12] = split[0];
    tr[13] = split[1];
    tr[14] = split[2];
    tr[15] = split[3];
    origin = Vector3<double>(split[0], split[1], split[2]);

    return true;
}
Example #25
0
CValue* CErrorValue::GetReplica()
{ 
	// who would want a copy of an error ?
	trace ("Error: ErrorValue::GetReplica() not implemented yet");
	assertd(false);

	return NULL;
}
Example #26
0
//
// Construct a string of multiple repeating characters
//
STR_String::STR_String(char c, int len) :
	pData(new char [len+8]),
	Len(len),
	Max(len+8)
{
	assertd(pData != NULL);
	memset(pData, c, len);
	pData[len] = 0;
}
Example #27
0
//
// Construct a string of multiple repeating characters
//
STR_String::STR_String(char c, int len) :
	m_data(new char[len + 8]),
	m_len(len),
	m_max(len + 8)
{
	assertd(this->m_data != NULL);
	memset(this->m_data, c, len);
	this->m_data[len] = 0;
}
Example #28
0
//
// Trim characters from the character set <set> from the left side of the string
//
STR_String&	STR_String::TrimLeft(char *set)
{
	int skip;
	assertd(pData != NULL);
	for (skip=0; Len && strchr(set, pData[skip]); skip++, Len--)
		{};
	memmove(pData, pData+skip, Len+1);
	return *this;
}
Example #29
0
//
// Trim whitespace from the left side of the string
//
STR_String&	STR_String::TrimLeft()
{
	int skip;
	assertd(pData != NULL);
	for (skip=0; isSpace(pData[skip]); skip++, Len--)
		{};
	memmove(pData, pData+skip, Len+1);
	return *this;
}
Example #30
0
//
// Construct a string from a pointer-to-ASCII-string and a length
//
STR_String::STR_String(const char *str, int len) :
	pData(new char [len+8]),
	Len(len),
	Max(len+8)
{
	assertd(pData != NULL);
	memcpy(pData, str, len);
	pData[len] = 0;
}