You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2007/05/16 23:40:53 UTC

svn commit: r538750 - in /incubator/uima/uimacpp/trunk/src: cas/xmiwriter.cpp test/src/test_primitivetypes.cpp

Author: eae
Date: Wed May 16 14:40:51 2007
New Revision: 538750

URL: http://svn.apache.org/viewvc?view=rev&rev=538750
Log:
UIMA-371 - Bhavani's patch

Modified:
    incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
    incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp

Modified: incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp?view=diff&rev=538750&r1=538749&r2=538750
==============================================================================
--- incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/cas/xmiwriter.cpp Wed May 16 14:40:51 2007
@@ -425,6 +425,7 @@
 
  string XmiWriter::arrayToString(FeatureStructure const & fs, char const * tag) {  
    stringstream str;
+	
    int typecode = internal::FSPromoter::demoteType(fs.getType());
    switch (typecode) {
       case internal::gs_tyIntArrayType: {
@@ -467,13 +468,14 @@
       case internal::gs_tyByteArrayType: {
         ByteArrayFS arrayfs(fs);
         size_t n = arrayfs.size();
-        for (size_t i=0; i < n;i++) {
-          char out[3];
-          sprintf(out,"%02X",arrayfs.get(i)); 
-          //itoa (arrayfs.get(i),out,16);
-          //printf ("itoahexadecimal: %s\n",out);
+				char * out = new char[3];
+				memset(out,0,3);
+        for (size_t i=0; i < n;i++) {      
+          sprintf(out,"%02X",0xFF & arrayfs.get(i)); 
+          //printf ("itoahexadecimal: %d %d\n",i, arrayfs.get(i));
           str << out[0] << out[1];			  
         }		  
+		
         break;
                                          }
       case internal::gs_tyShortArrayType: {
@@ -678,8 +680,10 @@
           if (f.isMultipleReferencesAllowed() ) {
             writeFeatureValue(os, fs, f);
           } else {
-            string str = arrayToString(fs.getFSValue(f), f.getName().asUTF8().c_str());          
-            os << " " << f.getName() << "=\"" << str << "\" ";  
+						if (fs.getFSValue(f).isValid()) {
+              string str = arrayToString(fs.getFSValue(f), f.getName().asUTF8().c_str());          
+              os << " " << f.getName() << "=\"" << str << "\" ";
+						}
           }	
           break;                               
         }
@@ -703,10 +707,12 @@
             if (f.isMultipleReferencesAllowed() ) {
               writeFeatureValue(os, fs, f);
             } else {
-              string str = listToString(fs.getFSValue(f), f.getName().asUTF8().c_str());          
-              if (listFS.isValid() && str.length() > 0) {
-                strcontent << str;					
-              }				  
+							if (fs.getFSValue(f).isValid()) {
+                string str = listToString(fs.getFSValue(f), f.getName().asUTF8().c_str());          
+                if (listFS.isValid() && str.length() > 0) {
+                  strcontent << str;					
+                }			
+							}
             }
           }
           break;                                        }
@@ -1229,6 +1235,7 @@
 
 
 /* ----------------------------------------------------------------------- */
+
 
 
 

Modified: incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp
URL: http://svn.apache.org/viewvc/incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp?view=diff&rev=538750&r1=538749&r2=538750
==============================================================================
--- incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp (original)
+++ incubator/uima/uimacpp/trunk/src/test/src/test_primitivetypes.cpp Wed May 16 14:40:51 2007
@@ -31,9 +31,9 @@
 #include "uima/internal_casserializer.hpp"
 #include "uima/internal_casdeserializer.hpp"
 #include "uima/taespecifierbuilder.hpp"
-
+#include "xercesc/util/Base64.hpp"
 #include <fstream>
-
+XERCES_CPP_NAMESPACE_USE
 #ifndef NDEBUG
 #define ASSERT_OR_THROWEXCEPTION(x) assert(x)
 #else
@@ -59,9 +59,12 @@
 float floats[] = {
                    (float)1.1, (float)2.2, (float)3.3, (float)4.4, (float)5.5
                  };
+
 char chars[] = {
-                 'a','b','c','c','d'
+                 1, 10, 'a','b','c','d','e',8,16,64,128,255
                };
+
+
 int shorts[] = {
                  10,20,30,40,50
                };
@@ -424,6 +427,7 @@
       "     <name>intArrayFeature</name>"
       "     <description></description>"
       "     <rangeTypeName>uima.cas.IntegerArray</rangeTypeName>"
+		//	 "     <multipleReferencesAllowed>true</multipleReferencesAllowed>"
       "   </featureDescription>"
       "   <featureDescription>"
       "     <name>floatArrayFeature</name>"
@@ -439,6 +443,7 @@
       "     <name>boolArrayFeature</name>"
       "     <description></description>"
       "     <rangeTypeName>uima.cas.BooleanArray</rangeTypeName>"
+		//	 "     <multipleReferencesAllowed>true</multipleReferencesAllowed>"
       "   </featureDescription>"
       "   <featureDescription>"
       "     <name>byteArrayFeature</name>"
@@ -449,11 +454,13 @@
       "     <name>shortArrayFeature</name>"
       "     <description></description>"
       "     <rangeTypeName>uima.cas.ShortArray</rangeTypeName>"
+		//	 "     <multipleReferencesAllowed>true</multipleReferencesAllowed>"
       "   </featureDescription>"
       "   <featureDescription>"
       "     <name>longArrayFeature</name>"
       "     <description></description>"
       "     <rangeTypeName>uima.cas.LongArray</rangeTypeName>"
+		//	 "     <multipleReferencesAllowed>true</multipleReferencesAllowed>"
       "   </featureDescription>"
       "   <featureDescription>"
       "     <name>doubleArrayFeature</name>"
@@ -529,8 +536,7 @@
     //LOG("deserialize XMI"); 
     XmiDeserializer::deserialize("testprimitivetypes.xmi", *trgCas);
     validateFS(*trgCas);
-    
-   
+        
     /* test blob serialization */
     LOG("UIMATEST_PRIMITIVETYPES test blob serialization");
     trgCas->reset();