Пример #1
0
void Phobos::System::WindowSDL::Open(const String_t &name, const UIntSize_t &size, void *parentWindow)
{

	SDL_Init(SDL_INIT_VIDEO);

	SDL_EnableUNICODE(1);

        #ifdef PH_WIN32
			unsigned int flags = 0;

			HWND parent = reinterpret_cast<HWND>(parentWindow);
			if(parent)
				flags = SDL_NOFRAME | SDL_RESIZABLE;

            SDL_SetVideoMode(size.m_tWidth, size.m_tHeight, 32, flags);

			if(parent)
			{
				HWND sdlHwnd = reinterpret_cast<HWND>(this->GetHandler());

				//not 100% trusted, but give us an extra check
				if(!IsWindow(parent))
				{
					PH_RAISE(INVALID_PARAMETER_EXCEPTION, "[WindowSDL::Open]", "Invalid parent window handle");
				}

				RECT parentRec;					
				GetClientRect(parent, &parentRec);
					
				//SetWindowPos( sdlHwnd, parent, 0, 0, parentRec.right, parentRec.bottom, ( 0 /*SWP_NOSIZE*/ | SWP_SHOWWINDOW ));
				MoveWindow(sdlHwnd, 0, 0,  parentRec.right, parentRec.bottom, true);
				SetParent(sdlHwnd, parent);			

				//SetWindowLong(sdlHwnd, GWL_STYLE, WS_MAXIMIZE);
			}

        #else
            SDL_SetVideoMode(rect.tWidth, rect.tHeight, 0, SDL_OPENGL);
        #endif

        #ifdef PH_LINUX
            SDL_GL_SetAttribute( SDL_GL_RED_SIZE,           8  );
            SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE,         8  );
            SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE,          8  );
            SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE,         16 );
        #endif

        SDL_WM_SetCaption(name.c_str(), NULL);
}
Пример #2
0
void Phobos::Register::Table::ParseSpecialValue(const String_t &idName, Parser &parser)
{
	String_t type;

	ParserTokens_e token;
	if((token = parser.GetToken(&type)) != TOKEN_ID)
	{
		RaiseParseException(parser, TOKEN_ID, token, type, "Phobos::Register::Table::ParseSpecialValue");
	}

	if(type.compare("CharMatrix") == 0)
	{
		if((token = parser.GetToken(NULL)) != TOKEN_OPEN_PAREN)
		{
			RaiseParseException(parser, TOKEN_OPEN_PAREN, token, type, "Phobos::Register::Table::ParseSpecialValue");
		}

		String_t matrix;
		String_t row;

		UInt16_t numColumns = 0;
		UInt16_t numRows = 0;

		bool first = true;
		for(;;)
		{
			token = parser.GetToken(&row);
			if(token == TOKEN_CLOSE_PAREN)
			{
				if(first)
				{
					//do not allow empty matrix
					RaiseParseException(parser, "matrix data", "closing parenthesis", "Phobos::Register::Table::ParseSpecialValue");
				}
					
				this->SetCharMatrix(idName, matrix, numRows, numColumns);
				break;
			}
			else if(token == TOKEN_STRING)
			{
				if(first)
				{
					numColumns = row.length();

					if(numColumns == 0)
						PH_RAISE(PARSER_EXCEPTION, "Phobos::Register::Table::ParseSpecialValue", "Matrix cannot be empty");

					first = false;
				}
				else if(numColumns != row.length())
				{
					PH_RAISE(PARSER_EXCEPTION, "Phobos::Register::Table::ParseSpecialValue", "Matrix rows should always have the same length");
				}

				matrix.append(row);
				++numRows;
			}
			else
			{
				RaiseParseException(parser, TOKEN_STRING, token, row, "Phobos::Register::Table::ParseSpecialValue");
			}
		}
	}	
	else
	{
		RaiseParseException(parser, " valid especial type, ie CharMatrix", type.c_str(), "Phobos::Register::Table::ParseSpecialValue");
	}
}
Пример #3
0
bool hatch::RegistryParser::ParseFile( Registry& registry, RegistryAction& action )
{
	if( !SkipEndLines() )
	{
		m_errorMessage << "Parameters expected after 'file {'";
		return false;
	}

	bool process = true;
	do
	{
		if( m_tokenizer.IsWord() )
		{
			const char* key = m_tokenizer.GetWord();
			if( Cmp( "action", key ) )
			{
				String_t value;
				if( !ParseWordValue( value ) )
				{
					m_errorMessage << "for action";
					return false;
				}

				if( !dung::StringToAction( value.c_str(), action.action ) )
				{
					m_errorMessage << _T("Unknown action ") << value;
					return false;
				}
			}
			else if( Cmp( "diff_path", key ) )
			{
				if( !ParseStringValue( action.diff_path ) )
				{
					m_errorMessage << _T("for diff_path");
					return false;
				}
			}
			else if( Cmp( "old_path", key ) )
			{
				if( !ParseStringValue( action.old_path ) )
				{
					m_errorMessage << _T("for old_path");
					return false;
				}
			}
			else if( Cmp( "new_path", key ) )
			{
				if( !ParseStringValue( action.new_path ) )
				{
					m_errorMessage << "for new_path";
					return false;
				}
			}
			else if( Cmp( "diff_method", key ) )
			{
				if( !ParseWordValue( action.diff_method ) )
				{
					m_errorMessage << "for diff_method";
					return false;
				}
			}
			else if( Cmp( "old_sha1", key ) )
			{
				String_t value;
				if( !ParseStringValue( value ) )
				{
					m_errorMessage << "for old_sha1";
					return false;
				}

				if( !dung::StringToSHA1( value.c_str(), action.oldSha1 ))
				{
					m_errorMessage << "Can't convert " << value << " to old_sha1";
					return false;
				}

				SCARAB_ASSERT( dung::SHA1_TO_TSTRING( action.oldSha1 ) == value );
			}
			else if( Cmp( "new_sha1", key ) )
			{
				String_t value;
				if( !ParseStringValue( value ) )
				{
					m_errorMessage << "for new_sha1";
					return false;
				}

				if( !dung::StringToSHA1( value.c_str(), action.newSha1 ))
				{
					m_errorMessage << "Can't convert " << value << " to new_sha1";
					return false;
				}

				SCARAB_ASSERT( dung::SHA1_TO_TSTRING( action.newSha1 ) == value );
			}
			else if( Cmp( "old_size", key ) )
			{
				String_t value;
				if( !ParseNumValue( value ) )
				{
					m_errorMessage << "for old_size";
					return false;
				}
				action.oldSize = _tchar_to_long( value.c_str() );
			}
			else if( Cmp( "new_size", key ) )
			{
				String_t value;
				if( !ParseNumValue( value ) )
				{
					m_errorMessage << "for new_size";
					return false;
				}
				action.newSize = _tchar_to_long( value.c_str() );
			}
		}
		else if( m_tokenizer.IsSymbol() && m_tokenizer.GetSymbol() == '}' )
			return true;

		if( !m_tokenizer.ParseNext() )
		{
			m_errorMessage << "'}' expected for 'file'";
			process = false;
		}
	} while( process );

	return false;
}