void raw_string::splitOnSubExp(subexp *pSubExp)
{
    const int iDigitSize = 8;
    char cCharDigit[iDigitSize];
    int iCurLevel = 0, iLastPr = 0, iPrevK;
	string_func strFunc;

    for (int i = 0, k = 0, iDelta = 0, iIndex = 0; cRawString[i]; i++){
        iIndex = i - iDelta;
		if (cRawString[i] == '(')
		{
			pSubExp[k].exp[iIndex] = '$';
			iCurLevel++;
			iDelta = i + 1;
			iPrevK = k;
			k = iLastPr;
			iLastPr++;
			k++;
			pSubExp[k].level = iCurLevel;
			floatToChar((float)k, cCharDigit);
			strFunc.concatStr(pSubExp[iPrevK].exp, cCharDigit);
		}
		else if (cRawString[i] == ')')
		{
            pSubExp[k].exp[iIndex] = '\0';
            k = (getParent(pSubExp, k) != -1) ? getParent(pSubExp, k) : 0;
            // We increase iDelta on 2 because we need to think NEXT iteration and not count '\0' symbol
            iDelta = i + 2 - strFunc.getStrLen(pSubExp[k].exp);
            iCurLevel--;
		}
		else if (cRawString[i] == '=')
		{
			// We suggest that in this case 'k' is always equal to 0 (it is very important in this 'if' statment )
			iCurLevel++;
			iDelta = i + 1;
			iLastPr++;
			k++;
			pSubExp[k].level = iCurLevel;
			floatToChar((float)k, cCharDigit);
			strFunc.concatStr(pSubExp[k - 1].exp, "=$");
			strFunc.concatStr(pSubExp[k - 1].exp, cCharDigit);
		}
		else
		{
			pSubExp[k].exp[iIndex] = cRawString[i];
		}
    }
}
Beispiel #2
0
void BufferConverters::floatToChar( char* c, const float* f, int n )
{
    for (int i = 0; i < n; ++i )
    {
        floatToChar( c[2*i], c[2*i+1], f[i] );
    }
}