Commit in lcio on MAIN
doc/versions.readme+91.54 -> 1.55
src/aid/EVENT/LCEvent.aid+6-41.12 -> 1.13
             /LCIO.aid+2-21.56 -> 1.57
src/cpp/include/IMPL/LCEventImpl.h+10-41.17 -> 1.18
src/cpp/src/IMPL/LCEventImpl.cc+271.21 -> 1.22
src/java/hep/lcio/exceptions/EventException.java+6-21.2 -> 1.3
src/java/hep/lcio/implementation/event/ILCEvent.java+33-21.12 -> 1.13
+93-14
7 modified files
enforce valid collection names in LCEvent.addCollection (like C/C++ variables)

lcio/doc
versions.readme 1.54 -> 1.55
diff -u -r1.54 -r1.55
--- versions.readme	8 Dec 2006 15:38:15 -0000	1.54
+++ versions.readme	2 Feb 2007 09:34:25 -0000	1.55
@@ -3,6 +3,15 @@
 ---------------------------------------------------------------
 
 =====================
+v01-08-01
+=====================
+  bug fix release
+  no changes in file format and API
+    - fixed problems with storing large arrays in SIO (C++) 
+    - fixed some issues with CellIDEncoder (C++) 
+    - enforce valid collection names (like C/C++ variables)
+
+=====================
 v01-08    
 =====================
 

lcio/src/aid/EVENT
LCEvent.aid 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- LCEvent.aid	7 Mar 2005 11:36:18 -0000	1.12
+++ LCEvent.aid	2 Feb 2007 09:34:26 -0000	1.13
@@ -8,7 +8,7 @@
  * the corresponding types.  
  *
  * @author gaede
- * @version $Id: LCEvent.aid,v 1.12 2005/03/07 11:36:18 gaede Exp $
+ * @version $Id: LCEvent.aid,v 1.13 2007/02/02 09:34:26 gaede Exp $
  * @see LCCollection
  */
 
@@ -55,9 +55,11 @@
      public LCCollection* takeCollection(const String& name) const throws DataNotAvailableException ;
 @endif
 
-    /** Adds a collection with the given name. Throws an exception if the name already
-     * exists in the event. NB: Adding collections is allowed even when the event is 'read only'.
-     * 
+    /** Adds a collection with the given name (has to be a valid C/C++ variable name). 
+     *	Throws an exception if the name already
+     *  exists in the event. NB: Adding collections is allowed even when the event is 'read only'.
+     *
+     *@see validateCollectionName
      *@throws EventException
      */ 
     public void addCollection(LCCollection* col ,const  String& name ) throws EventException ;

lcio/src/aid/EVENT
LCIO.aid 1.56 -> 1.57
diff -u -r1.56 -r1.57
--- LCIO.aid	21 Sep 2006 06:10:35 -0000	1.56
+++ LCIO.aid	2 Feb 2007 09:34:26 -0000	1.57
@@ -4,7 +4,7 @@
 @cpp{
 #define LCIO_MAJOR_VERSION 1
 #define LCIO_MINOR_VERSION 8
-#define LCIO_PATCH_LEVEL 0
+#define LCIO_PATCH_LEVEL 1
 
 #define LCIO_VERSION_GE( MAJV , MINV )  ( (  LCIO_MAJOR_VERSION  > MAJV ) || ( (LCIO_MAJOR_VERSION==MAJV) && ( LCIO_MINOR_VERSION >= MINV ) ) )
 
@@ -16,7 +16,7 @@
 /** Global constants used in LCIO.
  *
  * @author gaede
- * @version $Id: LCIO.aid,v 1.56 2006/09/21 06:10:35 gaede Exp $
+ * @version $Id: LCIO.aid,v 1.57 2007/02/02 09:34:26 gaede Exp $
  * @see LCObject
  * @see LCIO
  */

lcio/src/cpp/include/IMPL
LCEventImpl.h 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- LCEventImpl.h	15 Apr 2005 08:37:37 -0000	1.17
+++ LCEventImpl.h	2 Feb 2007 09:34:26 -0000	1.18
@@ -79,9 +79,11 @@
     virtual EVENT::LCCollection * takeCollection(const std::string & name) const 
       throw (EVENT::DataNotAvailableException, std::exception ) ;
 
-    /** Adds a collection with the given name. Throws an exception if the name already
-     * exists in the event. NB: Adding collections is allowed even when the event is 'read only'.
-     * 
+    /** Adds a collection with the given name (has to be a valid C/C++ variable name). 
+     *	Throws an exception if the name already
+     *  exists in the event. NB: Adding collections is allowed even when the event is 'read only'.
+     *
+     *@see validateCollectionName
      *@throws EventException
      */ 
     virtual void addCollection(EVENT::LCCollection * col, const std::string & name)  
@@ -149,7 +151,11 @@
   protected:
     void setAccessMode( int accessMode ) ;
     
-    
+    /**Tests the validity of a collection name. LCIO only accepts collection names starting with 
+     * (regular expression) [A-Za-z_] and continuing with [A-Za-z0-9_] (C/C++ variable name).
+     */
+    bool validateCollectionName( const char* name ) ;
+      
     // data members - declared protected to be accessible 
     // for friends of sub classes ...
     

lcio/src/cpp/src/IMPL
LCEventImpl.cc 1.21 -> 1.22
diff -u -r1.21 -r1.22
--- LCEventImpl.cc	15 Apr 2005 08:37:46 -0000	1.21
+++ LCEventImpl.cc	2 Feb 2007 09:34:26 -0000	1.22
@@ -121,6 +121,13 @@
 void  LCEventImpl::addCollection(LCCollection * col, const std::string & name) 
   throw (EventException, std::exception)  {
 
+  
+  if( ! validateCollectionName(name.c_str()) ){
+
+    throw EventException( std::string("LCEventImpl::addCollection() invalid name (has to be C/C++ name): "
+				      +name) ) ; 
+  }
+      
   // check if name exists
   if( _colMap.find( name ) != _colMap.end() )
     
@@ -192,5 +199,25 @@
 
 
 }
+  
+  /**Tests the validity of a collection name. SIO only accepts names starting with 
+   * (regular expression) [A-Za-z_] and continuing with [A-Za-z0-9_] (C/C++ variable name).
+   */
+  bool LCEventImpl::validateCollectionName( const char* name ){ //copy of SIO_functions::validateName
+    
+    if( *name < 0 ) 
+      return false ;
+    
+    if( !isalpha( (int)*name ) && *name != '_' ) 
+      return false ;
+    
+    for( name += 1; *name != '\0'; name++ ){
+      if( *name < 0 ) 
+	return false ;
+      if( !isalnum( (int)*name ) && *name != '_' ) 
+	return false ;
+    } 
+    return true ;
+  }
 
 }

lcio/src/java/hep/lcio/exceptions
EventException.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- EventException.java	15 Sep 2003 21:44:31 -0000	1.2
+++ EventException.java	2 Feb 2007 09:34:26 -0000	1.3
@@ -4,6 +4,10 @@
 /**
  * An exception thrown when adding a item which already exists to an event
  * @author Tony Johnson
- * @version $Id: EventException.java,v 1.2 2003/09/15 21:44:31 tonyj Exp $
+ * @version $Id: EventException.java,v 1.3 2007/02/02 09:34:26 gaede Exp $
  */
-public class EventException extends RuntimeException {}
+public class EventException extends RuntimeException {
+	public EventException(String s) {
+		super(s) ;
+	}
+}

lcio/src/java/hep/lcio/implementation/event
ILCEvent.java 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- ILCEvent.java	24 Sep 2004 10:39:29 -0000	1.12
+++ ILCEvent.java	2 Feb 2007 09:34:26 -0000	1.13
@@ -4,14 +4,17 @@
 import hep.lcio.event.LCEvent;
 import hep.lcio.event.LCParameters;
 import hep.lcio.exceptions.DataNotAvailableException;
+import hep.lcio.exceptions.EventException;
+
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 
 /**
  * A default implementation of LCEvent
+ * 
  * @author Tony Johnson
- * @version $Id: ILCEvent.java,v 1.12 2004/09/24 10:39:29 tonyj Exp $
+ * @version $Id: ILCEvent.java,v 1.13 2007/02/02 09:34:26 gaede Exp $
  */
 public class ILCEvent extends ILCObject implements LCEvent
 {
@@ -88,7 +91,9 @@
    
    public void addCollection(LCCollection col, String name)
    {
-      collections.put(name, col);
+       if( !isValidCollectionName(name))
+    	   throw new EventException("Invalid collection name: "+name) ;
+	   collections.put(name, col);
    }
    
    public void removeCollection(String name)
@@ -102,4 +107,30 @@
       return parameters;
    }
    
+
+   protected boolean isAlpha(char c) {
+	   return ( (c>='a'&&c<='z') || (c>='A'&&c<='Z') ) ;
+   }	
+   protected boolean isNum(char c) {
+	   return (c>='0' && c<='9') ;
+   }	
+   protected boolean isValidCollectionName(String name){
+
+      int len = name.length() ;
+	  if(len==0)
+	     return false ;
+	  char c0 = name.charAt(0) ;
+
+      if( !isAlpha( c0 ) && c0 != '_' ) 
+         return false ;
+	      
+	  for( int i=1; i< len; i++ ){
+	     char c = name.charAt(i) ;
+	     if( isAlpha(c) || isNum(c) || c == '_'   ) 
+	        continue ;
+	     else
+	        return false ;
+	  } 
+	  return true ;
+   }
 }
CVSspam 0.2.8