Index: XIOS/trunk/src/attribute_map.cpp
===================================================================
--- XIOS/trunk/src/attribute_map.cpp	(revision 647)
+++ XIOS/trunk/src/attribute_map.cpp	(revision 649)
@@ -250,26 +250,22 @@
       {
          oss << "SUBROUTINE xios(set_" << className << "_attr_hdl_)   &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-
-         *oss2 << "( " << className << "_hdl" ;
-
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName() << "_";
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName() << "_";
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -295,26 +291,22 @@
       {
          oss << "SUBROUTINE xios(get_" << className << "_attr_hdl_)   &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-
-         *oss2 << "( " << className << "_hdl" ;
-
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName() << "_";
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName() << "_";
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -340,26 +332,22 @@
       {
          oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl_)   &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-
-         *oss2 << "( " << className << "_hdl" ;
-
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName() << "_";
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName() << "_";
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -385,25 +373,22 @@
       {
          oss << "SUBROUTINE xios(set_" << className << "_attr_hdl)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -420,18 +405,17 @@
          oss << "CALL xios(set_" << className << "_attr_hdl_)  &" << iendl;
 
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
@@ -442,25 +426,22 @@
       {
          oss << "SUBROUTINE xios(get_" << className << "_attr_hdl)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -477,18 +458,17 @@
          oss << "CALL xios(get_" << className << "_attr_hdl_)  &" << iendl;
 
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
@@ -499,25 +479,22 @@
       {
          oss << "SUBROUTINE xios(is_defined_" << className << "_attr_hdl)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -534,18 +511,17 @@
          oss << "CALL xios(is_defined_" << className << "_attr_hdl_)  &" << iendl;
 
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
@@ -556,25 +532,22 @@
       {
          oss << "SUBROUTINE xios(set_" << className << "_attr)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_id" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_id";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -592,18 +565,18 @@
          oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl;
          oss << "CALL xios(set_" << className << "_attr_hdl_)   &" << iendl;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
@@ -614,25 +587,22 @@
       {
          oss << "SUBROUTINE xios(get_" << className << "_attr)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_id" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_id";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -650,18 +620,18 @@
          oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl;
          oss << "CALL xios(get_" << className << "_attr_hdl_)   &" << iendl;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
@@ -672,25 +642,22 @@
       {
          oss << "SUBROUTINE xios(is_defined_" << className << "_attr)  &" << iendl++;
-         ostringstream* oss2;
-         SuperClassMap::const_iterator it;
-         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
-
-         oss2 = new ostringstream;
-         *oss2 << "( " << className << "_id" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str() << std::endl;
-         oss << iendl;
-         delete oss2;
-         oss2 = new ostringstream;
+         SuperClassMap::const_iterator it;
+         SuperClassMap::const_iterator begin = SuperClassMap::begin(), end = SuperClassMap::end();
+
+         long startPos = oss.tellp();
+
+         oss << "( " << className << "_id";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
+         oss << std::endl;
+         oss << iendl;
 
          oss << "IMPLICIT NONE" << iendl++;
@@ -708,18 +675,18 @@
          oss << "CALL xios(get_" << className << "_handle)(" << className << "_id," << className << "_hdl)" << iendl;
          oss << "CALL xios(is_defined_" << className << "_attr_hdl_)   &" << iendl;
-         *oss2 << "( " << className << "_hdl" ;
-         for (it = begin; it != end; it++)
-         {
-           *oss2 << ", " << it->second->getName();
-           if (oss2->str().size() > 90)
-           {
-             oss << oss2->str() << "  &" << iendl;
-             delete oss2;
-             oss2 = new ostringstream;
-           }
-         }
-         *oss2 << " )";
-         oss << oss2->str();
-         delete oss2;
+
+         startPos = oss.tellp();
+
+         oss << "( " << className << "_hdl";
+         for (it = begin; it != end; it++)
+         {
+           oss << ", " << it->second->getName();
+           if (oss.tellp() - startPos > 90)
+           {
+             oss << "  &" << iendl;
+             startPos = oss.tellp();
+           }
+         }
+         oss << " )";
 
          oss << std::endl << (iendl -= 2);
