123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669 |
- #include "../idlib/precompiled.h"
- #pragma hdrstop
- size_t idDeclPDA::Size( void ) const {
- return sizeof( idDeclPDA );
- }
- void idDeclPDA::Print( void ) const {
- common->Printf( "Implement me\n" );
- }
- void idDeclPDA::List( void ) const {
- common->Printf( "Implement me\n" );
- }
- bool idDeclPDA::Parse( const char *text, const int textLength ) {
- idLexer src;
- idToken token;
- src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
- src.SetFlags( DECL_LEXER_FLAGS );
- src.SkipUntilString( "{" );
-
- while( 1 ) {
-
- if ( !src.ReadToken( &token ) ) {
- break;
- }
- if ( token == "}" ) {
- break;
- }
- if ( !token.Icmp( "name") ) {
- src.ReadToken( &token );
- pdaName = token;
- continue;
- }
- if ( !token.Icmp( "fullname") ) {
- src.ReadToken( &token );
- fullName = token;
- continue;
- }
- if ( !token.Icmp( "icon") ) {
- src.ReadToken( &token );
- icon = token;
- continue;
- }
- if ( !token.Icmp( "id") ) {
- src.ReadToken( &token );
- id = token;
- continue;
- }
- if ( !token.Icmp( "post") ) {
- src.ReadToken( &token );
- post = token;
- continue;
- }
- if ( !token.Icmp( "title") ) {
- src.ReadToken( &token );
- title = token;
- continue;
- }
- if ( !token.Icmp( "security") ) {
- src.ReadToken( &token );
- security = token;
- continue;
- }
- if ( !token.Icmp( "pda_email") ) {
- src.ReadToken( &token );
- emails.Append( token );
- declManager->FindType(DECL_EMAIL, token);
- continue;
- }
- if ( !token.Icmp( "pda_audio") ) {
- src.ReadToken( &token );
- audios.Append( token );
- declManager->FindType(DECL_AUDIO, token);
- continue;
- }
- if ( !token.Icmp( "pda_video") ) {
- src.ReadToken( &token );
- videos.Append( token );
- declManager->FindType(DECL_VIDEO, token);
- continue;
- }
- }
- if ( src.HadError() ) {
- src.Warning( "PDA decl '%s' had a parse error", GetName() );
- return false;
- }
- originalVideos = videos.Num();
- originalEmails = emails.Num();
- return true;
- }
- const char *idDeclPDA::DefaultDefinition( void ) const {
- return
- "{\n"
- "\t" "name \"default pda\"\n"
- "}";
- }
- void idDeclPDA::FreeData( void ) {
- videos.Clear();
- audios.Clear();
- emails.Clear();
- originalEmails = 0;
- originalVideos = 0;
- }
- void idDeclPDA::AddVideo( const char *name, bool unique ) const {
- if ( unique && ( videos.Find( name ) != NULL ) ) {
- return;
- }
- if ( declManager->FindType( DECL_VIDEO, name, false ) == NULL ) {
- common->Printf( "Video %s not found\n", name );
- return;
- }
- videos.Append( name );
- }
- void idDeclPDA::AddAudio( const char *name, bool unique ) const {
- if ( unique && ( audios.Find( name ) != NULL ) ) {
- return;
- }
- if ( declManager->FindType( DECL_AUDIO, name, false ) == NULL ) {
- common->Printf( "Audio log %s not found\n", name );
- return;
- }
- audios.Append( name );
- }
- void idDeclPDA::AddEmail( const char *name, bool unique ) const {
- if ( unique && ( emails.Find( name ) != NULL ) ) {
- return;
- }
- if ( declManager->FindType( DECL_EMAIL, name, false ) == NULL ) {
- common->Printf( "Email %s not found\n", name );
- return;
- }
- emails.Append( name );
- }
- void idDeclPDA::RemoveAddedEmailsAndVideos() const {
- int num = emails.Num();
- if ( originalEmails < num ) {
- while ( num && num > originalEmails ) {
- emails.RemoveIndex( --num );
- }
- }
- num = videos.Num();
- if ( originalVideos < num ) {
- while ( num && num > originalVideos ) {
- videos.RemoveIndex( --num );
- }
- }
- }
- void idDeclPDA::SetSecurity( const char *sec ) const {
- security = sec;
- }
- const int idDeclPDA::GetNumVideos() const {
- return videos.Num();
- }
- const int idDeclPDA::GetNumAudios() const {
- return audios.Num();
- }
- const int idDeclPDA::GetNumEmails() const {
- return emails.Num();
- }
- const idDeclVideo* idDeclPDA::GetVideoByIndex( int index ) const {
- if ( index >= 0 && index < videos.Num() ) {
- return static_cast< const idDeclVideo* >( declManager->FindType( DECL_VIDEO, videos[index], false ) );
- }
- return NULL;
- }
- const idDeclAudio* idDeclPDA::GetAudioByIndex( int index ) const {
- if ( index >= 0 && index < audios.Num() ) {
- return static_cast< const idDeclAudio* >( declManager->FindType( DECL_AUDIO, audios[index], false ) );
- }
- return NULL;
- }
- const idDeclEmail* idDeclPDA::GetEmailByIndex( int index ) const {
- if ( index >= 0 && index < emails.Num() ) {
- return static_cast< const idDeclEmail* >( declManager->FindType( DECL_EMAIL, emails[index], false ) );
- }
- return NULL;
- }
- size_t idDeclEmail::Size( void ) const {
- return sizeof( idDeclEmail );
- }
- void idDeclEmail::Print( void ) const {
- common->Printf( "Implement me\n" );
- }
- void idDeclEmail::List( void ) const {
- common->Printf( "Implement me\n" );
- }
- bool idDeclEmail::Parse( const char *_text, const int textLength ) {
- idLexer src;
- idToken token;
- src.LoadMemory( _text, textLength, GetFileName(), GetLineNum() );
- src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
- src.SkipUntilString( "{" );
- text = "";
-
- while( 1 ) {
- if ( !src.ReadToken( &token ) ) {
- break;
- }
- if ( token == "}" ) {
- break;
- }
- if ( !token.Icmp( "subject") ) {
- src.ReadToken( &token );
- subject = token;
- continue;
- }
- if ( !token.Icmp( "to") ) {
- src.ReadToken( &token );
- to = token;
- continue;
- }
- if ( !token.Icmp( "from") ) {
- src.ReadToken( &token );
- from = token;
- continue;
- }
- if ( !token.Icmp( "date") ) {
- src.ReadToken( &token );
- date = token;
- continue;
- }
- if ( !token.Icmp( "text") ) {
- src.ReadToken( &token );
- if ( token != "{" ) {
- src.Warning( "Email decl '%s' had a parse error", GetName() );
- return false;
- }
- while ( src.ReadToken( &token ) && token != "}" ) {
- text += token;
- }
- continue;
- }
- if ( !token.Icmp( "image") ) {
- src.ReadToken( &token );
- image = token;
- continue;
- }
- }
- if ( src.HadError() ) {
- src.Warning( "Email decl '%s' had a parse error", GetName() );
- return false;
- }
- return true;
- }
- const char *idDeclEmail::DefaultDefinition( void ) const {
- return
- "{\n"
- "\t" "{\n"
- "\t\t" "to\t5Mail recipient\n"
- "\t\t" "subject\t5Nothing\n"
- "\t\t" "from\t5No one\n"
- "\t" "}\n"
- "}";
- }
- void idDeclEmail::FreeData( void ) {
- }
- size_t idDeclVideo::Size( void ) const {
- return sizeof( idDeclVideo );
- }
- void idDeclVideo::Print( void ) const {
- common->Printf( "Implement me\n" );
- }
- void idDeclVideo::List( void ) const {
- common->Printf( "Implement me\n" );
- }
- bool idDeclVideo::Parse( const char *text, const int textLength ) {
- idLexer src;
- idToken token;
- src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
- src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
- src.SkipUntilString( "{" );
-
- while( 1 ) {
- if ( !src.ReadToken( &token ) ) {
- break;
- }
- if ( token == "}" ) {
- break;
- }
- if ( !token.Icmp( "name") ) {
- src.ReadToken( &token );
- videoName = token;
- continue;
- }
- if ( !token.Icmp( "preview") ) {
- src.ReadToken( &token );
- preview = token;
- continue;
- }
- if ( !token.Icmp( "video") ) {
- src.ReadToken( &token );
- video = token;
- declManager->FindMaterial( video );
- continue;
- }
- if ( !token.Icmp( "info") ) {
- src.ReadToken( &token );
- info = token;
- continue;
- }
- if ( !token.Icmp( "audio") ) {
- src.ReadToken( &token );
- audio = token;
- declManager->FindSound(audio);
- continue;
- }
- }
- if ( src.HadError() ) {
- src.Warning( "Video decl '%s' had a parse error", GetName() );
- return false;
- }
- return true;
- }
- const char *idDeclVideo::DefaultDefinition( void ) const {
- return
- "{\n"
- "\t" "{\n"
- "\t\t" "name\t5Default Video\n"
- "\t" "}\n"
- "}";
- }
- void idDeclVideo::FreeData( void ) {
- }
- size_t idDeclAudio::Size( void ) const {
- return sizeof( idDeclAudio );
- }
- void idDeclAudio::Print( void ) const {
- common->Printf( "Implement me\n" );
- }
- void idDeclAudio::List( void ) const {
- common->Printf( "Implement me\n" );
- }
- bool idDeclAudio::Parse( const char *text, const int textLength ) {
- idLexer src;
- idToken token;
- src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
- src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
- src.SkipUntilString( "{" );
-
- while( 1 ) {
- if ( !src.ReadToken( &token ) ) {
- break;
- }
- if ( token == "}" ) {
- break;
- }
- if ( !token.Icmp( "name") ) {
- src.ReadToken( &token );
- audioName = token;
- continue;
- }
- if ( !token.Icmp( "audio") ) {
- src.ReadToken( &token );
- audio = token;
- declManager->FindSound(audio);
- continue;
- }
- if ( !token.Icmp( "info") ) {
- src.ReadToken( &token );
- info = token;
- continue;
- }
- if ( !token.Icmp( "preview") ) {
- src.ReadToken( &token );
- preview = token;
- continue;
- }
- }
- if ( src.HadError() ) {
- src.Warning( "Audio decl '%s' had a parse error", GetName() );
- return false;
- }
- return true;
- }
- const char *idDeclAudio::DefaultDefinition( void ) const {
- return
- "{\n"
- "\t" "{\n"
- "\t\t" "name\t5Default Audio\n"
- "\t" "}\n"
- "}";
- }
- void idDeclAudio::FreeData( void ) {
- }
|