-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
*/
//================================================================================
-SauvReader* SauvReader::New(const char *fileName)
+SauvReader* SauvReader::New(const std::string& fileName)
{
- if ( !fileName || strlen(fileName) < 1 ) THROW_IK_EXCEPTION("Invalid file name");
+ if ( fileName.empty() ) THROW_IK_EXCEPTION("Invalid file name");
ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr< SauvUtilities::FileReader> parser;
// try to open as XRD
- parser = new XDRReader( fileName );
+ parser = new XDRReader( fileName.c_str() );
if ( parser->open() )
{
SauvReader* reader = new SauvReader;
}
// try to open as ASCII
- parser = new ASCIIReader( fileName );
+ parser = new ASCIIReader( fileName.c_str() );
if ( parser->open() )
{
SauvReader* reader = new SauvReader;
SauvUtilities::Group & grp = _iMed->_groups[ grpID-1 ];
if ( !grp._name.empty() ) // a group has several names
{ // create a group with subgroup grp and named grp.name
- _iMed->_groups.push_back(Group());
- _iMed->_groups.back()._groups.push_back( &_iMed->_groups[ grpID-1 ]);
- _iMed->_groups.back()._name = grp._name;
+ SauvUtilities::Group* newGroup = _iMed->addNewGroup();
+ newGroup->_groups.push_back( &_iMed->_groups[ grpID-1 ]);
+ newGroup->_name = grp._name;
}
grp._name=objectNames[i];
#ifdef _DEBUG
sameOrder = ( supports[j] == newGroups[ j % newGroups.size() ]);
if ( sameOrder )
{
- _iMed->_groups.push_back( SauvUtilities::Group() );
- group = & _iMed->_groups.back();
+ group = _iMed->addNewGroup( & newGroups );
group->_groups.swap( newGroups );
}
}