summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy')
-rw-r--r--Ivy/IvyApplication.cxx33
1 files changed, 19 insertions, 14 deletions
diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx
index 7d55bf1..cbb3ee6 100644
--- a/Ivy/IvyApplication.cxx
+++ b/Ivy/IvyApplication.cxx
@@ -2,7 +2,12 @@
//
#include "stdafx.h"
-//#include "libIvy.h"
+
+#ifdef _DEBUG
+#define DEBUG_NEW new(__FILE__, __LINE__)
+#define new DEBUG_NEW
+#endif
+
#include "IvyApplication.h"
#include "Regexp.h"
@@ -26,7 +31,7 @@ IvyApplication::IvyApplication(Ivy * bus)
IvyApplication::~IvyApplication()
{
// bus->RemoveApplication( this );
- for ( int i = 0; i < regexp_in.size(); i++)
+ for ( unsigned int i = 0; i < regexp_in.size(); i++)
delete regexp_in[i];
regexp_in.clear();
if ( m_hSocket != INVALID_SOCKET )
@@ -122,25 +127,27 @@ void IvyApplication::OnReceive(char * line)
exp = new Regexp( arg );
if ( !exp->CompiledOK() )
{
- string regerr = exp->GetErrorString();
- string err;
- err = "Error can't compile regexp '"+string(arg)+"' error "+regerr;
+ string err( "Error can't compile regexp '" );
+ err += arg;
+ err += "' error ";
+ err += exp->GetErrorString();
SendMsg( Error, Error, err.c_str() );
TRACE("IvyApplication %s\n",err.c_str());
return;
}
- regexp_in[ id ] = exp ;
+ regexp_in.reserve( id +1 );
+ regexp_in[ id ] = exp;
break;
case DelRegexp:
#ifdef DEBUG
TRACE("Regexp Delete id=%d\n", id);
#endif //DEBUG
- if ( regexp_in.find(id) != regexp_in.end() )
+ if ( regexp_in[id] )
{
exp = regexp_in[ id ];
delete exp;
- regexp_in.erase( id );
+ regexp_in[ id ] = NULL;
}
break;
case StartRegexp:
@@ -252,7 +259,7 @@ void IvyApplication::OnClose(int nErrorCode)
if ( AppConnectedCallbackCalled )
bus->CallApplicationDisconnectedCallback( this );
// bus->RemoveApplication( this );
- for ( int i = 0; i < regexp_in.size(); i++)
+ for ( unsigned int i = 0; i < regexp_in.size(); i++)
delete regexp_in[i];
regexp_in.clear();
Close();
@@ -262,12 +269,10 @@ int IvyApplication::SendMsg(const char *message)
{
int count = 0;
Regexp *exp;
- std::map<int,Regexp*>::iterator iter;
/* send to already connected */
- if ( !regexp_in.empty() )
- for ( iter = regexp_in.begin(); iter != regexp_in.end(); iter++ )
+ for ( unsigned int i = 0; i < regexp_in.size(); i++ )
{
- exp = (*iter).second;
+ exp = regexp_in[i];
if ( exp && exp->Match( message ) )
{
@@ -277,7 +282,7 @@ int IvyApplication::SendMsg(const char *message)
buffer += (*exp)[i];
buffer += ARG_END;
}
- SendMsg( Msg, (*iter).first, buffer.c_str() );
+ SendMsg( Msg, i, buffer.c_str() );
count++;
}
}