示例#1
0
文件: Markup.cpp 项目: kamilWLca/brix
INXString CMarkup::x_TextFromDoc( int nLeft, int nRight ) const
{
    // Convert XML friendly text to text as seen outside XML document
    // ampersand escape codes replaced with special characters e.g. convert "6>7" to "6>7"
    // Conveniently the result is always the same or shorter in byte length
    //
    static char* szaCode[] = { "lt;","amp;", "gt;", "apos;", "quot;" };
    static int anCodeLen[] = { 3,4,3,5,5 };
    static char* szSymbol = "<&>\'\"";
    INXString csText;
    const char* pSource = (const char*)m_csDoc;
    int nDestSize = nRight - nLeft + 1;
    char* pDest = csText.GetBuffer(nDestSize);
    //LPTSTR pDest = csText.GetBuffer(nDestSize);
    int nLen = 0;
    int nCharLen = 0;
    int nChar = nLeft;
    while ( nChar <= nRight )
    {
        if ( pSource[nChar] == '&')
        {
            // Look for matching &code;
            bool bCodeConverted = false;
            for ( int nMatch = 0; nMatch < 5; ++nMatch )
            {
                if ( nChar <= nRight - anCodeLen[nMatch]
                        && strncmp(szaCode[nMatch],&pSource[nChar+1],anCodeLen[nMatch]) == 0 )
                {
                    // Insert symbol and increment index past ampersand semi-colon
                    pDest[nLen++] = szSymbol[nMatch];
                    nChar += anCodeLen[nMatch] + 1;
                    bCodeConverted = true;
                    break;
                }
            }

            // If the code is not converted, leave it as is
            if ( ! bCodeConverted )
            {
                pDest[nLen++] = _T('&');
                ++nChar;
            }
        }
        else // not &
        {
            nCharLen = _tclen(&pSource[nChar]);
            _tccpy( &pDest[nLen], &pSource[nChar] );
            nLen += nCharLen;
            nChar += nCharLen;
        }
    }
    csText.ReleaseBuffer(nLen);
    return csText;
}
示例#2
0
//return -1: user break;
//return 0: no error
//return 1: lpPath is invalid
//return 2: can not create lpPath
int CPathDialog::MakeSurePathExists(LPCTSTR lpPath)
{
	INXString strMsg;
	int iRet;
	try
	{
		//validate path
		iRet=Touch(lpPath, TRUE);
		if(iRet!=0)
		{
			throw iRet;
		}

		if(_taccess(lpPath, 0)==0)
		{
			return (int)0;
		}

		strMsg.Format(c_FolderDoesNotExist, lpPath);
		if(AfxMessageBox(strMsg, MB_YESNO|MB_ICONQUESTION) != IDYES)
		{
			return (int)-1;
		}

		//create path
		iRet=Touch(lpPath, FALSE);
		if(iRet!=0)
		{
			throw iRet; 
		}

		return 0;
	}
	catch(int nErrCode)
	{
		switch(nErrCode)
		{
		case 1:
			strMsg.Format(c_szErrInvalidPath, lpPath);
			break;
		case 2:
		default:
			strMsg.Format(c_szErrCreatePath, lpPath);
			break;
		}

		AfxMessageBox(strMsg, MB_OK|MB_ICONEXCLAMATION);

	}

	return iRet;
}
示例#3
0
INXString cloneBackSlashes( const INXString &csText )
{
	INXString csRetval = "";

	for(int i=0;i<csText.GetLength();i++)
	{
		csRetval.AppendChar(((INXString)csText)[i] );
		if( ((INXString)csText)[i] == '\\'){
			csRetval.AppendChar( '\\' );
		}
	}
	return csRetval;
}
示例#4
0
文件: Markup.cpp 项目: kamilWLca/brix
INXString CMarkup::x_TextToDoc( char* szText, bool bAttrib ) const
{
    // Convert text as seen outside XML document to XML friendly
    // replacing special characters with ampersand escape codes
    // E.g. convert "6>7" to "6&gt;7"
    //
    // &lt;   less than
    // &amp;  ampersand
    // &gt;   greater than
    //
    // and for attributes:
    //
    // &apos; apostrophe or single quote
    // &quot; double quote
    //
    static char* szaReplace[] = { "&lt;", "&amp;", "&gt;", "&apos;", "&quot;"};
    const char* pFind = bAttrib? "<&>\'\"":"<&>";
    INXString csText;
    const char* pSource = szText;
    int nDestSize = strlen(pSource);
    nDestSize += nDestSize / 10 + 7;
    char* pDest = csText.GetBuffer(nDestSize);
    int nLen = 0;
    char cSource = *pSource;
    char* pFound;
    while ( cSource )
    {
        if ( nLen > nDestSize - 6 )
        {
            csText.ReleaseBuffer(nLen);
            nDestSize *= 2;
            pDest = csText.GetBuffer(nDestSize);
        }
        if ( (pFound=(char*)strchr(pFind,cSource)) != NULL )
        {
            pFound = szaReplace[pFound-pFind];
            strcpy(&pDest[nLen],pFound);
            nLen += strlen(pFound);
        }
        else
        {
            _tccpy( &pDest[nLen], pSource );
            nLen += _tclen( pSource );
        }
        pSource += _tclen( pSource );
        cSource = *pSource;
    }
    csText.ReleaseBuffer(nLen);
    return csText;
}
示例#5
0
文件: Markup.cpp 项目: kamilWLca/brix
void CMarkup::x_DocChange( int nLeft, int nReplace, const INXString& csInsert )
{
    // Insert csInsert int m_csDoc at nLeft replacing nReplace chars
    // Do this with only one buffer reallocation if it grows
    //
    int nDocLength = m_csDoc.GetLength();
    int nInsLength = csInsert.GetLength();

    // Make sure nLeft and nReplace are within bounds
    nLeft = max( 0, min( nLeft, nDocLength ) );
    nReplace = max( 0, min( nReplace, nDocLength-nLeft ) );

    // Get pointer to buffer with enough room
    int nNewLength = nInsLength + nDocLength - nReplace;
    int nBufferLen = nNewLength;
    char* pDoc = m_csDoc.GetBuffer( nBufferLen );

    // Move part of old doc that goes after insert
    if ( nLeft+nReplace < nDocLength )
        memmove( &pDoc[nLeft+nInsLength], &pDoc[nLeft+nReplace], (nDocLength-nLeft-nReplace)*sizeof(char) );

    // Copy insert
    //const char* tempChar = csInsert;
    memcpy( &pDoc[nLeft], (const char*)csInsert, nInsLength*sizeof(char));

    // Release
    m_csDoc.ReleaseBuffer( nNewLength );
}
示例#6
0
文件: Project.cpp 项目: pdrezet/brix
void Project::RenameXport(INXPOSITION iconPos, DEP* pDEP, INXString &csNewPortLabel) 
{
	INXString csProjectDir, csOldPortLabel;
	ConData* icon;

	pProjMData->getProjectDir(csProjectDir);
	icon = (ConData*) pDEP->condata->GetAt(iconPos);
	if (icon->m_csIconType.Find("XINPUT") == -1 && icon->m_csIconType.Find("XOUTPUT") == -1 && 
		icon->m_csIconType != "XSTART" && icon->m_csIconType != "XFINISH") {
		AfxMessageBox("Can only rename Xports.");
		return;
	}

	csOldPortLabel = icon->description;
	csNewPortLabel = icon->description;
	// Prompt user for new port name
	CBlockPortLabelDialog dialog(csOldPortLabel, icon, pDEP);
	if (dialog.DoModal() == IDOK) {
		csNewPortLabel = dialog.GetPortLabel();
		csNewPortLabel.MakeLower();
	}

	// Rename Xport
	icon->description = csNewPortLabel;
}
示例#7
0
文件: Markup.cpp 项目: kamilWLca/brix
bool CMarkup::x_SetAttrib( int iPos, char* szAttrib, char* szValue )
{
    // Set attribute in iPos element
    TokenPos token( m_csDoc );
    int nInsertAt;
    if ( iPos && m_nNodeType == MNT_ELEMENT )
    {
        token.nNext = m_aPos[iPos].nStartL + 1;
        nInsertAt = m_aPos[iPos].nStartR - (m_aPos[iPos].IsEmptyElement()?1:0);
    }
    else
        return false;

    // Create insertion text depending on whether attribute already exists
    int nReplace = 0;
    INXString csInsert;
    if ( x_FindAttrib( token, szAttrib ) )
    {
        // Replace value only
        // Decision: for empty value leaving attrib="" instead of removing attrib
        csInsert = x_TextToDoc( szValue, true );
        nInsertAt = token.nL;
        nReplace = token.nR-token.nL+1;
    }
    else
    {
        // Insert string name value pair
        INXString csFormat(" ");
        csFormat += (wxChar*)szAttrib;
        csFormat += _T("=\"");
        csFormat += x_TextToDoc( szValue, true );
        csFormat += _T("\"");
        csInsert = csFormat;
    }

    x_DocChange( nInsertAt, nReplace, csInsert );
    int nAdjust = csInsert.GetLength() - nReplace;
    m_aPos[iPos].nStartR += nAdjust;
    m_aPos[iPos].AdjustEnd( nAdjust );
    x_Adjust( iPos, nAdjust );
    MARKUP_SETDEBUGSTATE;
    return true;
}
示例#8
0
// This function assigns a line ID to the ouput or finish port
void SODL::AssignLineID2OtherPort(ConData *blob, int portType, int portNum, long lineID) {
	long othericonid = -1;
	int otherportno = 0;
	static int stop_checking = 0; //This is messy but prevents too many user prompts.
	int response;

	ConData *blob2;
	
	if (portType == INPUTPORT) {
		othericonid = blob->inputport[portNum]->line.othericonid;
		otherportno = blob->inputport[portNum]->line.otherportno;
	}
	else if (portType == STARTPORT) {
		othericonid = blob->startport[portNum]->line.othericonid;
		otherportno = blob->startport[portNum]->line.otherportno;
	}

	//	kwhite - Handle null object if widget file corrupt or missing
	if ( (blob2 = GetFlatIconFromID(othericonid)) == NULL)
	{
		INXString message;
		message.Format("Missing component linked to %s ID %d.\nThe Application may not work as expected.\nPlease seek assistance from nCapsa.\nContinue?", blob->description, blob->identnum);
		if(stop_checking==0)
			response = AfxMessageBox(message ,MB_YESNO);

		if (response == IDNO) 
			stop_checking = 1;	
		
		return;
	}

	// set the line id in the appropriate output port
	if (portType == INPUTPORT) {
		blob2->outputport[otherportno]->setLineID(lineID);
	}
	else if (portType == STARTPORT) {
		blob2->finishport[otherportno]->setLineID(lineID);
	}

}
示例#9
0
DBTIMESTAMP parseTimeStamp( INXString &cs )
{
	DBTIMESTAMP ts ;
	memset( &ts, 0, sizeof(DBTIMESTAMP) ); 

	INXString cs2;
    const size_t newsize = 100;
    char buff[newsize];
int i;
	for(i=0;i<cs.GetLength();i++)
		buff[i] = (char) cs.GetAt(i);

	buff[i+1] = '\0';

	sscanf_s( buff,
		//(char *)lptStr, 
		//dum,
		"%4d-%2d-%2d %2d:%2d:%2d:%9d", 
		&ts.year, &ts.month, &ts.day, &ts.hour, &ts.minute, &ts.second, &ts.fraction );

	return ts;
}
示例#10
0
void parseSodlWidgetData( const INXString &fileLine, INXString &widgetTag, INXString &targetFileName )
{

	// A GUI tag is preceded by %%%_ which needs to be removed from the GUI file
	widgetTag = fileLine;
	widgetTag.Delete(0, 4);
	// Now that the %%%_ has gone, store value for target file name also.
	targetFileName = widgetTag;

	// where is space between widget tag and target file name
	int posnOfSeparatorSpace = widgetTag.Find(INXString(" "));

	// get the characters of the widget tag (ie up to, not including, the space).
	widgetTag = widgetTag.Left(posnOfSeparatorSpace);

	// Now get the target file name.

	int length = targetFileName.GetLength();
	targetFileName = targetFileName.Right(length-posnOfSeparatorSpace-1);

	return;

}
示例#11
0
BOOL CExportDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CFileFind finder;
	INXString fileName;
	int bWorking = finder.FindFile(workDir + USERDEFDIR + "*.prg");
	
	// read in ini files and construct menu tree
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		fileName = finder.GetFileName();
		// Remove .prg
		fileName.MakeReverse();
		fileName.Delete(0,4);
		fileName.MakeReverse();
		m_Library.AddString(fileName);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#12
0
文件: Markup.cpp 项目: kamilWLca/brix
bool CMarkup::x_AddElem( char* szName, char* szValue, bool bInsert, bool bAddChild )
{
    if ( bAddChild )
    {
        // Adding a child element under main position
        if ( ! m_iPos )
            return false;
    }
    else if ( m_iPosParent == 0 )
    {
        // Adding root element
        if ( IsWellFormed() )
            return false;


        // Locate after any version and DTD
        m_aPos[0].nEndL = m_csDoc.GetLength();
    }

    // Locate where to add element relative to current node
    int iPosParent, iPosBefore, nOffset = 0, nLength = 0;
    if ( bAddChild )
    {
        iPosParent = m_iPos;
        iPosBefore = m_iPosChild;
    }
    else
    {
        iPosParent = m_iPosParent;
        iPosBefore = m_iPos;
    }
    int nFlags = bInsert?1:0;
    x_LocateNew( iPosParent, iPosBefore, nOffset, nLength, nFlags );
    bool bEmptyParent = m_aPos[iPosParent].IsEmptyElement();
    if ( bEmptyParent || m_aPos[iPosParent].nStartR + 1 == m_aPos[iPosParent].nEndL )
        nOffset += 2;

    // Create element and modify positions of affected elements
    // If no szValue is specified, an empty element is created
    // i.e. either <NAME>value</NAME> or <NAME/>
    //
    int iPos = x_GetFreePos();
    m_aPos[iPos].nStartL = nOffset;

    // Set links
    m_aPos[iPos].iElemParent = iPosParent;
    m_aPos[iPos].iElemChild = 0;
    m_aPos[iPos].iElemNext = 0;
    if ( iPosBefore )
    {
        // Link in after iPosBefore
        m_aPos[iPos].iElemNext = m_aPos[iPosBefore].iElemNext;
        m_aPos[iPosBefore].iElemNext = iPos;
    }
    else
    {
        // First child
        m_aPos[iPos].iElemNext = m_aPos[iPosParent].iElemChild;
        m_aPos[iPosParent].iElemChild = iPos;
    }

    // Create string for insert
    INXString csInsert;
    int nLenName = strlen(szName);
    int nLenValue = szValue? strlen(szValue) : 0;
    if ( ! nLenValue )
    {
        // <NAME/> empty element
        csInsert = "<";
        csInsert += (wxChar*)szName;
        csInsert += _T("/>\r\n");
        m_aPos[iPos].nStartR = m_aPos[iPos].nStartL + nLenName + 2;
        m_aPos[iPos].nEndL = m_aPos[iPos].nStartR - 1;
        m_aPos[iPos].nEndR = m_aPos[iPos].nEndL + 1;
    }
    else
    {
        // <NAME>value</NAME>
        INXString csValue = x_TextToDoc( szValue );
        nLenValue = csValue.GetLength();
        csInsert.Append(wxT("<"));
        csInsert += (wxChar*)szName;
        csInsert += wxT(">");
        csInsert += csValue;
        csInsert += wxT("</");
        csInsert += (wxChar*)szName;
        csInsert += wxT(">\r\n");
        m_aPos[iPos].nStartR = m_aPos[iPos].nStartL + nLenName + 1;
        m_aPos[iPos].nEndL = m_aPos[iPos].nStartR + nLenValue + 1;
        m_aPos[iPos].nEndR = m_aPos[iPos].nEndL + nLenName + 2;
    }

    // Insert
    int nReplace = 0, nLeft = m_aPos[iPos].nStartL;
    if ( bEmptyParent )
    {
        INXString csParentTagName = x_GetTagName(iPosParent);
        INXString csFormat;
        csFormat.Append(wxT(">\r\n"));
        csFormat += csInsert;
        csFormat += wxT("</");
        csFormat += csParentTagName;
        csInsert = csFormat;
        nLeft = m_aPos[iPosParent].nStartR - 1;
        nReplace = 1;
        // x_Adjust is going to update all affected indexes by one amount
        // This will satisfy all except the empty parent
        // Here we pre-adjust for the empty parent
        // The empty tag slash is removed
        m_aPos[iPosParent].nStartR -= 1;
        // For the newly created end tag, see the following example:
        // <A/> (len 4) becomes <A><B/></A> (len 11)
        // In x_Adjust everything will be adjusted 11 - 4 = 7
        // But the nEndL of element A should only be adjusted 5
        m_aPos[iPosParent].nEndL -= (csParentTagName.GetLength() + 1);
    }
    else if ( m_aPos[iPosParent].nStartR + 1 == m_aPos[iPosParent].nEndL )
    {
        csInsert = _T("\r\n") + csInsert;
        nLeft = m_aPos[iPosParent].nStartR + 1;
    }
    x_DocChange( nLeft, nReplace, csInsert );
    x_Adjust( iPos, csInsert.GetLength() - nReplace );

    if ( bAddChild )
        x_SetPos( m_iPosParent, iPosParent, iPos );
    else
        x_SetPos( iPosParent, iPos, 0 );
    return true;
}
示例#13
0
文件: Markup.cpp 项目: kamilWLca/brix
int CMarkup::x_ParseElem( int iPosParent )
{
    // This is either called by SetDoc, x_AddSubDoc, or itself recursively
    // m_aPos[iPosParent].nEndL is where to start parsing for the child element
    // This returns the new position if a tag is found, otherwise zero
    // In all cases we need to get a new ElemPos, but release it if unused
    //
    int iPos = x_GetFreePos();
    m_aPos[iPos].nStartL = m_aPos[iPosParent].nEndL;
    m_aPos[iPos].iElemParent = iPosParent;
    m_aPos[iPos].iElemChild = 0;
    m_aPos[iPos].iElemNext = 0;

    // Start Tag
    // A loop is used to ignore all remarks tags and special tags
    // i.e. <?xml version="1.0"?>, and <!-- comment here -->
    // So any tag beginning with ? or ! is ignored
    // Loop past ignored tags
    TokenPos token( m_csDoc );
    token.nNext = m_aPos[iPosParent].nEndL;
    INXString csName;
    while ( csName.IsEmpty() )
    {
        // Look for left angle bracket of start tag
        m_aPos[iPos].nStartL = token.nNext;
        if ( ! x_FindChar( token.szDoc, m_aPos[iPos].nStartL, _T('<') ) )
            return x_ParseError( "Element tag not found");

        // Set parent's End tag to start looking from here (or later)
        m_aPos[iPosParent].nEndL = m_aPos[iPos].nStartL;

        // Determine whether this is an element, or bypass other type of node
        token.nNext = m_aPos[iPos].nStartL + 1;
        if ( x_FindToken( token ) )
        {
            if ( token.bIsString )
                return x_ParseError( "Tag starts with quote" );
            char cFirstChar = m_csDoc[token.nL];
            if ( cFirstChar == '?' || cFirstChar == '!' )
            {
                token.nNext = m_aPos[iPos].nStartL;
                if ( ! x_ParseNode(token) )
                    return x_ParseError( "Invalid node");
            }
            else if ( cFirstChar != _T('/') )
            {
                csName = x_GetToken( token );
                // Look for end of tag
                if ( ! x_FindChar(token.szDoc, token.nNext, _T('>')) )
                    return x_ParseError("End of tag not found");
            }
            else
                return x_ReleasePos(); // probably end tag of parent
        }
        else
            return x_ParseError( "Abrupt end within tag");
    }
    m_aPos[iPos].nStartR = token.nNext;

    // Is ending mark within start tag, i.e. empty element?
    if ( m_csDoc[m_aPos[iPos].nStartR-1] == _T('/') )
    {
        // Empty element
        // Close tag left is set to ending mark, and right to open tag right
        m_aPos[iPos].nEndL = m_aPos[iPos].nStartR-1;
        m_aPos[iPos].nEndR = m_aPos[iPos].nStartR;
    }
    else // look for end tag
    {
        // Element probably has contents
        // Determine where to start looking for left angle bracket of end tag
        // This is done by recursively parsing the contents of this element
        int iInner, iInnerPrev = 0;
        m_aPos[iPos].nEndL = m_aPos[iPos].nStartR + 1;
        while ( (iInner = x_ParseElem( iPos )) > 0 )
        {
            // Set links to iInner
            if ( iInnerPrev )
                m_aPos[iInnerPrev].iElemNext = iInner;
            else
                m_aPos[iPos].iElemChild = iInner;
            iInnerPrev = iInner;

            // Set offset to reflect child
            m_aPos[iPos].nEndL = m_aPos[iInner].nEndR + 1;
        }
        if ( iInner == -1 )
            return -1;

        // Look for left angle bracket of end tag
        if ( ! x_FindChar( token.szDoc, m_aPos[iPos].nEndL, _T('<') ) )
            return x_ParseError("End tag of %s element not found", csName );

        // Look through tokens of end tag
        token.nNext = m_aPos[iPos].nEndL + 1;
        int nTokenCount = 0;
        while ( x_FindToken( token ) )
        {
            ++nTokenCount;
            if ( ! token.bIsString )
            {
                // Is first token not an end slash mark?
                if ( nTokenCount == 1 && m_csDoc[token.nL] != _T('/') )
                    return x_ParseError( (char*)("Expecting end tag of element %s"), csName );

                else if ( nTokenCount == 2 && ! token.Match(csName) )
                    return x_ParseError( (char*)("End tag does not correspond to %s"), csName );

                // Else is it a right angle bracket?
                else if ( m_csDoc[token.nL] == _T('>') )
                    break;
            }
        }

        // Was a right angle bracket not found?
        if ( ! token.szDoc[token.nL] || nTokenCount < 2 )
            return x_ParseError( (char*)("End tag not completed for element %s"), csName );
        m_aPos[iPos].nEndR = token.nL;
    }

    // Successfully parsed element (and contained elements)
    return iPos;
}
示例#14
0
void parseGuiFile(
				const INXString &csFileName, 
				std::vector< LgbTextIconEssentialData_t > &textIcons, 
				std::vector< LgbPatchIconEssentialData_t > &patchIcons, 
				std::vector< LgbImageIconEssentialData_t > &imageIcons,
				std::vector< LgbTextStyleEssentialData_t > &vTextStyles)
{
	
/* Load background bitmaps from layout file */

	char seps[]   = ",\t\n\r";
	char sepsWithSpace[]   = " ,\t\n\r";


	INXString dummy;

	char fileLine[STD_LINE_LENGTH];
	char versionTagLabel[STD_FIELD_LENGTH];
	char versionStr[STD_FIELD_LENGTH];
	
	char * tokenPtr[24];

	char *token1 = NULL;
	char *next_token = NULL;
	char *pDummyChar = NULL;
	
	bool newFormat;

	// read first line to see if format is 'new' or not.
	bool gettingVersion = true;
	bool keepGoing = true;
	bool isComment = false;

	std::ifstream datafile( csFileName );
	int count = 0;
	int nTokens;
	int nonCommentLineNumber = 0;

	LgbTextIconEssentialData_t textIconDat;
	LgbPatchIconEssentialData_t patchIconDat;
	LgbImageIconEssentialData_t imageIconDat;
	LgbTextStyleEssentialData_t textStyleDat;

	LgbIconEssentialData_t basicDat;

	while ((!datafile.eof()) && (!datafile.bad())) {	

		// Get the first non-comment line, and determine the version.
		// Treat this differently from the rest of the file, as the format
		// maybe prehistoric (no version 1st-line) or may be modern.
		// If non-prehistoric, we can rely on comma-separators being present, but not otherwise.

		while( gettingVersion ){

			datafile.getline(fileLine, STD_LINE_LENGTH);
			if(fileLine[0] != '#' ) {

				if(strstr( fileLine, "Version")==fileLine){

					token1 = strtok_s( fileLine, sepsWithSpace, &next_token );	
					strcpy_s(versionTagLabel, STD_FIELD_LENGTH, token1 );

					token1 = strtok_s( NULL, sepsWithSpace, &next_token);
					strcpy_s(versionStr, STD_FIELD_LENGTH, token1 );

					newFormat = true;

				} else { //if(strstr( fileLine, "Version")==fileLine)

					strcpy_s(versionTagLabel, STD_FIELD_LENGTH, "Pre-Historic" );
					strcpy_s(versionStr, STD_FIELD_LENGTH, "0.0.0" );
					newFormat = false;
				} // if(strstr( fileLine, "Version")!=fileLine)

				gettingVersion = false;

			} // if(fileLine[0] != '#' )

		} // while( gettingVersion )

		datafile.getline(fileLine, STD_LINE_LENGTH);

		count = 0;
		token1 = strtok_s( fileLine, seps, &next_token );	
		tokenPtr[count++] = token1;

		while ( token1 != NULL )
		{
			token1 = strtok_s( NULL, seps, &next_token);	
			tokenPtr[count++] = token1;
		}

		nTokens = count - 1;

		if( tokenPtr[0] != NULL ){

			if( (tokenPtr[0])[0] != '#' )
			{
				
				if(newFormat){

				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				// NEW FORMAT
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

					dummy = tokenPtr[0];
					basicDat.tag = dummy.TrimLeft().TrimRight();
	

					dummy = tokenPtr[1];
					basicDat.type = dummy.TrimLeft().TrimRight(); 
					
					if (basicDat.type == "TextStyle") {
						textStyleDat.csClass = basicDat.tag;
						textStyleDat.csFont = tokenPtr[2];
						textStyleDat.alpha = atoi(tokenPtr[3]);
						textStyleDat.red = atoi(tokenPtr[4]);
						textStyleDat.green = atoi(tokenPtr[5]);
						textStyleDat.blue = atoi(tokenPtr[6]);
					}
					else {
						basicDat.xTopLft = atoi( tokenPtr[2] );
						basicDat.yTopLft = atoi( tokenPtr[3] );
						basicDat.width = atoi( tokenPtr[4] );				
						basicDat.height = atoi( tokenPtr[5] );

						basicDat.zPos = atoi( tokenPtr[6] );

						INXString csWarnings;
						if(cleanupGuiLayoutBasics( basicDat, csWarnings  ))
							AfxMessageBox(csWarnings);
					}



					if ( (basicDat.type == "GUI_Bitmap") ||  (basicDat.type == "GUI_Image") ){

						imageIconDat.basics = basicDat;

						imageIconDat.alpha= atoi( tokenPtr[7] );

					// strip-off any leading or trailing spaces..
						dummy =  tokenPtr[8];
						imageIconDat.bitmapFileName = dummy.TrimLeft().TrimRight(); 
						//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

						// new item added to GUI file for images, set to 0 for old versions
						imageIconDat.lockAspect = 0;
						if (nTokens > 9) {
							imageIconDat.lockAspect = atoi( tokenPtr[9] );
						}


					} else if ((basicDat.type == "GUI_TextBox") || (basicDat.type == "GUI_TextBox1") || (basicDat.type == "GUI_TextBox2")) {

						textIconDat.basics = basicDat;

						textIconDat.fgAlpha  = atoi( tokenPtr[7] );
						textIconDat.fgRed  = atoi( tokenPtr[8] );
						textIconDat.fgGreen  = atoi( tokenPtr[9] );
						textIconDat.fgBlue  = atoi( tokenPtr[10] );

						textIconDat.bgAlpha  = atoi( tokenPtr[11] );
						textIconDat.bgRed  = atoi( tokenPtr[12] );
						textIconDat.bgGreen  = atoi( tokenPtr[13] );
						textIconDat.bgBlue  = atoi( tokenPtr[14] );
						
						
						if ((basicDat.type == "GUI_TextBox2")) {
							textIconDat.csFont = tokenPtr[15];
							textIconDat.leftIndent = atoi(tokenPtr[16]);
							textIconDat.rightIndent = atoi(tokenPtr[17]);
							textIconDat.topIndent = atoi(tokenPtr[18]);
							textIconDat.bottomIndent = atoi(tokenPtr[19]);
							textIconDat.lineSpacing = atoi(tokenPtr[20]);
							//textIconDat.fonttype  = atoi( tokenPtr[15] );
							//textIconDat.fonsize  = atoi( tokenPtr[16] );
						}
						else {
							textIconDat.basics.type = "GUI_TextBox2";
							textIconDat.csFont = "lsr";
							textIconDat.leftIndent = 10;
							textIconDat.rightIndent = 10;
							textIconDat.topIndent = 10;
							textIconDat.bottomIndent = 10;
							textIconDat.lineSpacing = 12;
						}

					} else if ( basicDat.type == "GUI_Patch" ){

						patchIconDat.basics = basicDat;

						patchIconDat.bgAlpha  = atoi( tokenPtr[7] );
						patchIconDat.bgRed  = atoi( tokenPtr[8] );
						patchIconDat.bgGreen  = atoi( tokenPtr[9] );
						patchIconDat.bgBlue  = atoi( tokenPtr[10] );

					} 
					else if (basicDat.type == "TextStyle") {
					}
					else {
						assert(1==0);
					}

				} else {

				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				// PREVIOUS FORMAT
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

					dummy = tokenPtr[0];
					basicDat.tag = dummy.TrimLeft().TrimRight(); 

					dummy = tokenPtr[1];
					basicDat.type = dummy.TrimLeft().TrimRight();
					

					basicDat.xTopLft = atoi( tokenPtr[2] );
					basicDat.yTopLft = atoi( tokenPtr[3] );
					basicDat.width = atoi( tokenPtr[4] );				
					basicDat.height = atoi( tokenPtr[5] );
					basicDat.location = atoi( tokenPtr[6] );

					INXString csWarnings;
					if(cleanupGuiLayoutBasics( basicDat, csWarnings  ))
						AfxMessageBox(csWarnings);

					if ( (basicDat.type == "GUI_Bitmap") ||  (basicDat.type == "GUI_Image") ){

						imageIconDat.basics = basicDat;

					// strip-off any leading or trailing spaces..
						dummy =  tokenPtr[8];
						dummy = dummy.TrimLeft().TrimRight(); 
						
						if(dummy == "dummy.bmp")
							dummy=ICON_PLACEHOLDER_FILE;

						imageIconDat.bitmapFileName = dummy;

						basicDat.zPos = atoi( tokenPtr[9]);
						imageIconDat.alpha = 255;

					} else {

						textIconDat.basics = basicDat;

						textIconDat.bgRed  = atoi( tokenPtr[8] );
						textIconDat.bgGreen  = atoi( tokenPtr[9] );
						textIconDat.bgBlue  = atoi( tokenPtr[10] );
						textIconDat.fgRed  = atoi( tokenPtr[11] );
						textIconDat.fgGreen  = atoi( tokenPtr[12] );
						textIconDat.fgBlue  = atoi( tokenPtr[13] );
						textIconDat.basics.zPos = atoi( tokenPtr[14] );

						textIconDat.fgAlpha = 255;
						textIconDat.bgAlpha = 255;
					}
				} 

				if (basicDat.type=="GUI_Bitmap") {

					INXString projDir = "";
					imageIcons.push_back( imageIconDat );

				} else if (basicDat.type=="GUI_TextBox" || basicDat.type=="GUI_TextBox2") {

					textIcons.push_back(  textIconDat );

				} else if (basicDat.type=="GUI_Patch") {

					patchIcons.push_back(  patchIconDat );
				}
				else if (basicDat.type == "TextStyle") {
					vTextStyles.push_back(textStyleDat);
				}
				else{


					// unknown type!
					assert(1==0);

				}

			} 

		}  // if( token1!= NULL )
		
	}

	datafile.close();

}
示例#15
0
void Encapsulate::OnOK() 
{
	bool errorFlag = FALSE;
	INXString strText = "";
	UINT i;
	
	// update attributes such as m_BlockName
	UpdateData(TRUE);
	//get the text from the textboxes
	for (i=1; i<=inNum; i++) {
		strText = "";
		int len = inEdit[i]->LineLength(inEdit[i]->LineIndex(0));
		if (len) {
			inEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		INXString x(strText.MakeLower());
		inNames[i] = strText.MakeLower();
	}
	for (i=1; i<=outNum; i++) {
		strText = "";
		int len = outEdit[i]->LineLength(outEdit[i]->LineIndex(0));
		if (len) {
			outEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		outNames[i] = (INXString)strText.MakeLower();
	}
	for (i=1; i<=startNum; i++) {
		strText = "";
		int len = startEdit[i]->LineLength(startEdit[i]->LineIndex(0));
		if (len) {
			startEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		startNames[i] = strText.MakeLower();
	}
	for (i=1; i<=finishNum; i++) {
		strText = "";
		int len = finishEdit[i]->LineLength(finishEdit[i]->LineIndex(0));
		if (len) {
			finishEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		finishNames[i] = strText.MakeLower();
	}

	// Check port names are not empty strings and are unique
	for (i=1; i<=inNum; i++) {
		// check port names
		if (inNames[i] == "") {
			AfxMessageBox("WARNING: Enter a port name for " + inLabels[i]);
			errorFlag = TRUE;
		}
		for (UINT j=1; j<=inNum; j++) {
			if (i!=j && inNames[i] == inNames[j]) {
				AfxMessageBox("WARNING: " + inLabels[i] + " is not unique.");
				errorFlag = TRUE;
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=outNum; i++) {
			// check port names
			if (outNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + outLabels[i]);
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=outNum; j++) {
				if (i!=j && outNames[i] == outNames[j]) {
					AfxMessageBox("WARNING: " + outLabels[i] + " is not unique.");
					errorFlag = TRUE;					
				}
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=startNum; i++) {
			// check port names
			if (startNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + startLabels[i]);					
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=startNum; j++) {
				if (i!=j && startNames[i] == startNames[j]) {
					AfxMessageBox("WARNING: " + startLabels[i] + " is not unique.");
					errorFlag = TRUE;
				}
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=finishNum; i++) {
			// check port names
			if (finishNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + finishLabels[i]);
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=finishNum; j++) {
				if (i!=j && finishNames[i] == finishNames[j]) {
					AfxMessageBox("WARNING: " + finishLabels[i] + " is not unique.");
					errorFlag = TRUE;
				}
			}
		}
	}

	
	if (!errorFlag) {
		CDialog::OnOK();
	}
}
示例#16
0
int parseLines( INXString &csTextBlock, std::list<INXString> &rLines )
{

	// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	// Split-up the received text into new-line terminated pieces.
	// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

	// 1st of all, chop-off any \n's at the beginning of the string, as these are effectively 0-length
	// lines, which are not worth processing further.

	rLines.clear();

	int charPos = csTextBlock.Find('\n');
	int len = csTextBlock.GetLength();
	while(charPos == 0){
		csTextBlock = csTextBlock.Right(len-1);
		charPos = csTextBlock.Find('\n');
		len = csTextBlock.GetLength();
	}


	charPos = csTextBlock.Find('\n');
	len = csTextBlock.GetLength();

	if ( charPos == -1 ) {
		// There is no '\n' at all.  Treat the string as just one line.
		rLines.push_back(csTextBlock);
		csTextBlock = "";

	} else {

		while( charPos != -1 ){

			// The \n is in the middle somewhere - get the left-most substring
			rLines.push_back(csTextBlock.Left(charPos+1) );
			csTextBlock = csTextBlock.Right(csTextBlock.GetLength() - 1 - charPos);

			charPos = csTextBlock.Find('\n');
			len = csTextBlock.GetLength();

		} // while( charPos != -1 )

	} // if(charPos != -1)

	len = csTextBlock.GetLength();

	if ( csTextBlock.GetLength() > 0 ) {
		// Pushthe last non- \n terminated string
		rLines.push_back(csTextBlock);
		csTextBlock = "";

	}
	return rLines.size();

}