Beispiel #1
0
int GetMapColumns(const string& File, int Type)
{
    std::string tmpString = "";
    int totCols = 0;
    int tmpCols = 0;
    
    ifstream tmpHandle(File.c_str());
    
    if (!tmpHandle)
    {
        return -1;
    }
    while (!tmpHandle.eof())
    {
        size_t found;
        std::getline(tmpHandle, tmpString);
        switch (Type)
        {
            case MAP_FILE_MAP:
            {
                for (int i=0; i<tmpString.size(); i++)
                {
                    if (tmpString[i] == ':')
                    {
                        tmpCols++;
                    }
                }
                if (totCols < tmpCols)
                {
                    totCols = tmpCols;
                }
                tmpCols = 0;
                break;
            }
            case MAP_FILE_XSB:
            {
                found = tmpString.find_first_of("#");
                if (found != string::npos)
                {
                    tmpCols = tmpString.size();
                    if (totCols < tmpCols)
                    {
                        totCols = tmpCols;
                    }
                    tmpCols = 0;
                }
                break;
            }
        }
        tmpString.clear();
    }
    
    return totCols;
}
Beispiel #2
0
	//--------------------------------------------------------------------------------
	bool CPipeConnector::HandlePendingConnectionResult( bool bConnected )
	{
		_WINQ_FCONTEXT( "CPipeConnector::HandlePendingConnectionResult" );

		bool bPendingIO = false;

		// Overlapped ConnectNamedPipe should return zero. 
		if( bConnected ) 
		{
			//printf("ConnectNamedPipe failed with %d.\n", GetLastError()); 
			return false;
		}

		switch( m_ErrorHelper.GetLastError() ) 
		{ 
		// The overlapped connection in progress. 
		case ErrorIOPending: 
			bPendingIO = true; 
			break; 
   
		// Client is already connected, so signal an event.    
		case ErrorPipeConnected: 
			{
				OVERLAPPED* pOverlapped = reinterpret_cast< OVERLAPPED* >( GetSyncObject() );
				CSyncHandle tmpHandle( pOverlapped->hEvent, true ); 
				CEvent tmpEvent( tmpHandle );
				if( tmpEvent.Set() ) 
				{
					tmpHandle.Drop();
					break; 
				}
			}   
		// If an error occurs during the connect operation... 
		default: 
			{
				//printf("ConnectNamedPipe failed with %d.\n", GetLastError());
				return false;
			}
		} 

		return bPendingIO;		
	}
Beispiel #3
0
int GetMapLines(const string& File, int Type)
{
    std::string tmpString = "";
    int totLines = 0;
    
    ifstream tmpHandle(File.c_str());
    if (!tmpHandle)
    {
        return -1;
    }
    while (!tmpHandle.eof())
    {
        size_t found;
        std::getline(tmpHandle, tmpString);
        switch (Type)
        {
            case MAP_FILE_MAP:
            {
                found = tmpString.find_first_of(":");
                break;
            }
            case MAP_FILE_XSB:
            {
                found = tmpString.find_first_of("#");
                break;
            }
        }
        if (found != string::npos)
        {
            totLines++;
        }
        tmpString.clear();
    }
    
    return totLines;
}