global __lib__dir__
if __lib__dir__: return __lib__dir__
import platform
- if platform.architecture()[0] == "64bit":
- if platform.machine() == "ia64":
- __lib__dir__ = "lib"
- else:
- __lib__dir__ = "lib"
- else:
- __lib__dir__ = "lib"
+ __lib__dir__ = "lib"
return __lib__dir__
# -----------------------------------------------------------------------------
global __lib__dir__
if __lib__dir__: return __lib__dir__
import platform
- if platform.architecture()[0] == "64bit":
- if platform.machine() == "ia64":
- __lib__dir__ = "lib"
- else:
- __lib__dir__ = "lib"
- else:
- __lib__dir__ = "lib"
+ __lib__dir__ = "lib"
return __lib__dir__
# -----------------------------------------------------------------------------
# ================================================================
#
#AC_PREREQ(2.59)
-AC_INIT([Salome2 Project], [4.1.1], [paul.rascle@edf.fr], [SalomeKer])
+AC_INIT([Salome2 Project], [4.1.2], [paul.rascle@edf.fr], [SalomeKer])
# AC_CONFIG_AUX_DIR defines an alternative directory where to find the auxiliary
# scripts such as config.guess, install-sh, ...
AM_INIT_AUTOMAKE([tar-pax])
#AC_CONFIG_HEADER([config.h])
-XVERSION=0x040101
+XVERSION=0x040102
AC_SUBST(XVERSION)
# set up MODULE_NAME variable for dynamic construction of directories (resources, etc.)
\section S2_sal_appl Application Directory
-There is two ways for creation of an application directory
+There are two ways for creation of an application directory, <b>the recommended way is
+the second, easier to configure.</b>
<ol>
<li>
<b>First way - references to different module directories</b>
-The script createAppli.sh in ${KERNEL_ROOT_DIR}/bin/SALOME creates an
-application directory with the given path in parameter. ${APPLI} is a path
+The script createAppli.sh in ${KERNEL_ROOT_DIR}/bin/salome creates an
+application directory with the given path in parameter. The path given, ${APPLI}, is
relative to ${HOME}.
The directory is only a skeleton, the user has to edit several files to
<b>Second and easiest way - one single virtual install directory</b>
The user must create a %SALOME application configuration file by modifying a
-copy of ${KERNEL_ROOT_DIR}/bin/SALOME/config_appli.xml.
+copy of ${KERNEL_ROOT_DIR}/bin/salome/config_appli.xml.
The file describes the list of %SALOME modules used in the application, with
their respective installation path. The configuration file also defines the
path of an existing script which sets the %SALOME prerequisites,
The following command::
\code
-python <KERNEL_ROOT_DIR>/bin/SALOME/appli_gen.py --prefix=<install directory> --config=<configuration file>
+python <KERNEL_ROOT_DIR>/bin/salome/appli_gen.py --prefix=<install directory> --config=<configuration file>
\endcode
creates a virtual installation of %SALOME in the application directory ${APPLI}
(bin, lib, doc, share...), with, for each file (executable, script, data,
library, resources...), symbolic links to the actual file.
+<b>Note: it is recommended to set the environment for %SALOME prerequisites
+before invoking the above command, in order to use the same python as SALOME,
+otherwise installation may be wrong</b>
-Providing an existing an existing script for %SALOME prerequisites (the same one
+Providing an existing script for %SALOME prerequisites (the same one
used for modules compilation, or given with the modules installation), the
installation works without further modification for a single computer (unless
some modules needs a special environment not defined in the above script).
For a distributed application (several computers), one must copy and adapt
-CatalogResources.xml from ${KERNEL_ROOT_DIR}/bin/SALOME/appliskel (see below).
+CatalogResources.xml from ${KERNEL_ROOT_DIR}/bin/salome/appliskel (see below).
</li>
</ol>
With the first way of installation, each user **must define** his own
configuration for these scripts, following the above rules.
-With the virtual installation (second way, above), env.d
-scripts are built automatically.
+<b>With the virtual installation (second way, above), env.d
+scripts are built automatically.</b>
**The following is only an example proposed by createAppli.sh, (first way of installation) not working as it is**.
- runAppli
Launches a %SALOME Session
- (similar to ${KERNEL_ROOT_DIR}/bin/SALOME/runSALOME but with a different
- name to avoid confusions).
+ (similar to ${KERNEL_ROOT_DIR}/bin/salome/runSalome but with a different
+ name to avoid confusions). See parameters below.
- runSession
Launches a shell script in the %SALOME application environment, with access
It is also possible to use runSession, then python.
- runTests
- Similar to runSession, used for unit testing. runSession tries to use an
+ Similar to runSession, used for unit testing, but runSession tries to use an
already existing naming service definition from a running session (hostname
- and port number), runTests defines a new configuration for naming service
+ and port number), and runTests defines a new configuration for naming service
(new port number).
</li>
<li>
For remote calls, %SALOME uses one script.
- runRemote.sh
- This script is mainly used to launch containers. The first 2 arguments
- define the hostname and port userd for naming service, the remaining
+ This script is mainly used to launch containers. The first 3 arguments
+ define the hostname and port userd for naming service, plus a working directory, the remaining
arguments define the command to execute.
</li>
<li>
kill all the %SALOME servers of **all the sessions** on a given computer::
\code
-./runSession killSALOME.py
+./runSession killSalome.py
\endcode
-Remember! it's the same idea in *Windows (R) operating system* (Microsoft and Windows are either registered trademarks or trademarks of
+Remember! it's the same idea in <b>Windows (R) operating system</b> (Microsoft and Windows are either registered trademarks or trademarks of
Microsoft Corporation in the United States and/or other countries) :
use the start menu to stop...
the naming service port number::
\code
-./runSession killSALOMEWithPort 2810
+./runSession killSalomeWithPort 2810
\endcode
Note that the port number of the last launched session can be found on Linux,
Example of script (test_session_geom.py):
\code
-import SALOME_session
-SALOME_session.startSession(modules=["GEOM"])
+import salome_session
+salome_session.startSession(modules=["GEOM"])
import GEOM_usinggeom
raw_input("Press a key and the servers will be killed ...")
\endcode
python
\endcode
-Import %SALOME module. SALOME_init() without arguments creates a new study
+Import %SALOME module. salome_init() without arguments creates a new study
in the running session (note: SALOME_init(n) attachs to a running session whose
studyId is n)::
\code
-import SALOME
-SALOME.SALOME_init()
+import salome
+salome.salome_init()
\endcode
An example of script given with SMESH::
AC_CHECKING(for LIB_LOCATION_SUFFIX)
LIB_LOCATION_SUFFIX=""
- case "$build_cpu" in
- x86_64*) LIB_LOCATION_SUFFIX="" ;;
- *) LIB_LOCATION_SUFFIX="" ;;
- esac
AC_SUBST(LIB_LOCATION_SUFFIX)
AC_MSG_RESULT(LIB_LOCATION_SUFFIX is $LIB_LOCATION_SUFFIX)
splitter = ";"
path=salome_path.split(splitter)
import platform
-if platform.architecture()[0] == "64bit":
- if platform.machine() == "ia64":
- libdir = "lib"
- else:
- libdir = "lib"
-else:
- libdir = "lib"
+libdir = "lib"
for rep in path:
# Import all *_shared_modules in rep
for f in glob.glob(os.path.join(rep,libdir,"python"+sys.version[:3],"site-packages","salome","shared_modules","*_shared_modules.py")):
#include "SALOME_LifeCycleCORBA.hxx"
#ifndef WNT
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
+#include CORBA_CLIENT_HEADER(SALOME_Session)
+#include CORBA_CLIENT_HEADER(DSC_Engines)
+#include CORBA_CLIENT_HEADER(SALOME_Registry)
+#include CORBA_CLIENT_HEADER(SALOMEDS)
#else
#include "SALOME_ModuleCatalog.hh"
+#include "SALOME_Session.hh"
+#include "DSC_Engines.hh"
+#include "SALOME_Registry.hh"
+#include "SALOMEDS.hh"
#endif
#include "SALOME_ContainerManager.hxx"
#include "SALOME_Component_i.hxx"
return resManager._retn();
}
+//=============================================================================
+/*! Public -
+ * shutdown all the SALOME servers except SALOME_Session_Server, omniNames and notifd
+ */
+//=============================================================================
+
+void SALOME_LifeCycleCORBA::shutdownServers()
+{
+ // get each Container from NamingService => shutdown it
+ // (the order is inverse to the order of servers initialization)
+
+ SALOME::Session_var session = SALOME::Session::_nil();
+ CORBA::Long pid = 0;
+ CORBA::Object_var objS = _NS->Resolve("/Kernel/Session");
+ if (!CORBA::is_nil(objS))
+ {
+ session = SALOME::Session::_narrow(objS);
+ if (!CORBA::is_nil(session))
+ {
+ pid = session->getPID();
+ session->ping();
+ }
+ }
+
+ string hostname = GetHostname();
+
+ // 1) SalomeLauncher
+ CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher");
+ Engines::SalomeLauncher_var launcher = Engines::SalomeLauncher::_narrow(objSL);
+ if (!CORBA::is_nil(launcher) && (pid != launcher->getPID()))
+ launcher->Shutdown();
+
+ // 2) ConnectionManager
+ CORBA::Object_var objCnM=_NS->Resolve("/ConnectionManager");
+ Engines::ConnectionManager_var connMan=Engines::ConnectionManager::_narrow(objCnM);
+ if ( !CORBA::is_nil(connMan) && ( pid != connMan->getPID() ) )
+ connMan->ShutdownWithExit();
+
+ // 3) SALOMEDS
+ CORBA::Object_var objSDS = _NS->Resolve("/myStudyManager");
+ SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow(objSDS) ;
+ if ( !CORBA::is_nil(studyManager) && ( pid != studyManager->getPID() ) )
+ studyManager->Shutdown();
+
+ // 4) ModuleCatalog
+ CORBA::Object_var objMC=_NS->Resolve("/Kernel/ModulCatalog");
+ SALOME_ModuleCatalog::ModuleCatalog_var catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objMC);
+ if ( !CORBA::is_nil(catalog) && ( pid != catalog->getPID() ) )
+ catalog->shutdown();
+
+ // 5) Registry
+ CORBA::Object_var objR = _NS->Resolve("/Registry");
+ Registry::Components_var registry = Registry::Components::_narrow(objR);
+ if ( !CORBA::is_nil(registry) && ( pid != registry->getPID() ) )
+ registry->Shutdown();
+}
+
+//=============================================================================
+/*! Public -
+ * shutdown omniNames and notifd
+ */
+//=============================================================================
+
+void SALOME_LifeCycleCORBA::killOmniNames()
+{
+ string portNumber (::getenv ("NSPORT") );
+ if ( !portNumber.empty() )
+ {
+ string cmd ;
+ cmd = string( "ps -eo pid,command | grep -v grep | grep -E \"omniNames.*")
+ + portNumber
+ + string("\" | awk '{cmd=sprintf(\"kill -9 %s\",$1); system(cmd)}'" );
+ MESSAGE(cmd);
+ system ( cmd.c_str() );
+ }
+
+ // NPAL 18309 (Kill Notifd)
+ if ( !portNumber.empty() )
+ {
+ string cmd = ("import pickle, os; ");
+ cmd += string("from killSalomeWithPort import getPiDict; ");
+ cmd += string("filedict=getPiDict(") + portNumber + "); ";
+ cmd += string("f=open(filedict, 'r'); ");
+ cmd += string("pids=pickle.load(f); ");
+ cmd += string("m={}; ");
+ cmd += string("[ m.update(i) for i in pids ]; ");
+ cmd += string("pids=filter(lambda a: 'notifd' in m[a], m.keys()); ");
+ cmd += string("[ os.kill(pid, 9) for pid in pids ]; ");
+ cmd += string("os.remove(filedict); ");
+ cmd = string("python -c \"") + cmd +"\" > /dev/null";
+ MESSAGE(cmd);
+ system( cmd.c_str() );
+ }
+}
//=============================================================================
/*! Protected -
Engines::ContainerManager_ptr getContainerManager();
Engines::ResourcesManager_ptr getResourcesManager();
+ void shutdownServers();
+ static void killOmniNames();
+
protected:
/*! Establish if a component called "componentName" in a container called
string SALOMEDSImpl_AttributeTableOfInteger::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
- theStream.precision(64);
-
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Rows titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
- theStream << l << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
for(MI p = myTable.begin(); p != myTable.end(); p++) {
- theStream << p->first << "\n";
- theStream << p->second << "\n";
+ sprintf(buffer, "%d\n%d\n", p->first, p->second);
+ aString += buffer;
}
- string aString((char*)theStream.rdbuf()->str());
+ delete []buffer;
return aString;
}
+
+
void SALOMEDSImpl_AttributeTableOfInteger::Load(const string& value)
{
- istrstream theStream(value.c_str(), strlen(value.c_str()));
- Backup();
+ vector<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
- int i, j, l;
+ Backup();
- char anExtChar;
+ pos = 0;
std::string aStr;
//Title
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
- theStream >> myNbRows;
+ myNbRows = strtol(v[pos++].c_str(), NULL, 10);
//Rows titles
myRows.clear();
for(i=1; i<=myNbRows; i++) {
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
- theStream >> myNbColumns;
+ myNbColumns = strtol(v[pos++].c_str(), NULL, 10);
//Columns titles
myCols.clear();
for(i=1; i<=myNbColumns; i++) {
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTable.clear();
for(i=1; i<=l; i++) {
- int aKey, aValue;
- theStream >> aKey;
- theStream >> aValue;
+ int aKey = strtol(v[pos++].c_str(), NULL, 10);
+ int aValue = strtol(v[pos++].c_str(), NULL, 10);
myTable[aKey] = aValue;
}
}
string SALOMEDSImpl_AttributeTableOfReal::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Rows titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
- theStream << l << "\n";
- char *aBuffer = new char[128];
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
for(MI p = myTable.begin(); p != myTable.end(); p++) {
- theStream << p->first << "\n";
- sprintf(aBuffer, "%.64e", p->second);
- theStream << aBuffer << "\n";
+ sprintf(buffer, "%d\n%.64e\n", p->first, p->second);
+ aString += buffer;
}
-
- delete []aBuffer;
- string aString((char*)theStream.rdbuf()->str());
+
+ delete []buffer;
return aString;
}
void SALOMEDSImpl_AttributeTableOfReal::Load(const string& value)
{
- istrstream theStream(value.c_str(), strlen(value.c_str()));
- Backup();
+ vector<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
- int i, j, l;
+ Backup();
- char anExtChar;
+ pos = 0;
std::string aStr;
//Title
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
- theStream >> myNbRows;
+ myNbRows = strtol(v[pos++].c_str(), NULL, 10);
//Rows titles
myRows.clear();
for(i=1; i<=myNbRows; i++) {
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
- theStream >> myNbColumns;
+ myNbColumns = strtol(v[pos++].c_str(), NULL, 10);
//Columns titles
myCols.clear();
for(i=1; i<=myNbColumns; i++) {
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTable.clear();
for(i=1; i<=l; i++) {
- int aKey;
- double aValue;
- theStream >> aKey;
- theStream >> aValue;
+ int aKey = strtol(v[pos++].c_str(), NULL, 10);
+ double aValue = strtod(v[pos++].c_str(), NULL);
myTable[aKey] = aValue;
}
string SALOMEDSImpl_AttributeTableOfString::Save()
{
- ostrstream theStream;
+ string aString;
+ char* buffer = new char[1024];
int i, j, l;
-
+
//Title
l = myTitle.size();
- theStream << l << "\n";
- for(i=0; i<l; i++)
- theStream << myTitle[i] << "\n";
-
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(i=0; i<l; i++) {
+ aString += myTitle[i];
+ aString +='\n';
+ }
+
//Nb rows
- theStream << myNbRows << "\n";
+ sprintf(buffer, "%d\n", myNbRows);
+ aString+=buffer;
- //Rows titles
+ //Row titles
for(i=0; i<myNbRows; i++) {
l = myRows[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myRows[i][j] << "\n";
- }
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myRows[i][j];
+ aString += '\n';
+ }
+ }
//Nb columns
- theStream << myNbColumns << "\n";
+ sprintf(buffer, "%d\n", myNbColumns);
+ aString+=buffer;
//Columns titles
for(i=0; i<myNbColumns; i++) {
l = myCols[i].size();
- theStream << l << "\n";
- for(j=0; j<l; j++)
- theStream << myCols[i][j] << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
+ for(j=0; j<l; j++) {
+ aString += myCols[i][j];
+ aString += '\n';
+ }
}
//Store the table values
l = myTable.size();
- theStream << l << "\n";
+ sprintf(buffer, "%d\n", l);
+ aString+=buffer;
for(MI p = myTable.begin(); p!=myTable.end(); p++) {
if (p->second.size()) { // check empty string in the value table
- theStream << p->first << "\n";
+ sprintf(buffer, "%d\n", p->first);
+ aString += buffer;
unsigned long aValueSize = p->second.size();
- theStream<<aValueSize << "\n";
- theStream.write(p->second.c_str(),aValueSize);
- theStream<<"\n";
+ sprintf(buffer, "%ld\n", aValueSize);
+ aString +=buffer;
+ aString += p->second;
+ aString += '\n';
} else { // write index only of kind: "0key"; "05", for an example
- theStream << "0" << p->first << "\n";
+ sprintf(buffer, "0%d\n", p->first);
+ aString+=buffer;
}
}
- string aString((char*)theStream.rdbuf()->str());
+
+ delete []buffer;
return aString;
}
void SALOMEDSImpl_AttributeTableOfString::Load(const string& value)
{
- istrstream theStream(value.c_str(), strlen(value.c_str()));
- Backup();
-
- theStream.seekg(0, ios::end);
- long aSize = theStream.tellg();
- theStream.seekg(0, ios::beg);
+ vector<string> v;
+ int i, j, l, pos, aSize = (int)value.size();
+ for(i = 0, pos = 0; i<aSize; i++) {
+ if(value[i] == '\n') {
+ v.push_back(value.substr(pos, i-pos));
+ pos = i+1;
+ }
+ }
- int i, j, l;
- char *aValueString = new char[aSize];
+ Backup();
- char anExtChar;
+ pos = 0;
std::string aStr;
//Title
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTitle = std::string(l, 0);
for(i=0; i<l; i++) {
- theStream >> anExtChar;
- myTitle[i] = anExtChar;
+ myTitle[i] = v[pos++][0];
}
//Nb rows
- theStream >> myNbRows;
+ myNbRows = strtol(v[pos++].c_str(), NULL, 10);
//Rows titles
myRows.clear();
- for(i=0; i<myNbRows; i++) {
- theStream >> l;
+ for(i=1; i<=myNbRows; i++) {
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myRows.push_back(aStr);
}
//Nb columns
- theStream >> myNbColumns;
+ myNbColumns = strtol(v[pos++].c_str(), NULL, 10);
//Columns titles
myCols.clear();
- for(i=0; i<myNbColumns; i++) {
- theStream >> l;
+ for(i=1; i<=myNbColumns; i++) {
+ l = strtol(v[pos++].c_str(), NULL, 10);
aStr = std::string(l,0);
for(j=0; j<l; j++) {
- theStream >> anExtChar;
- aStr[j] = anExtChar;
+ aStr[j] = v[pos++][0];
}
myCols.push_back(aStr);
}
//Restore the table values
- string aValue;
- theStream >> l;
+ l = strtol(v[pos++].c_str(), NULL, 10);
myTable.clear();
- theStream.getline(aValueString,aSize,'\n');
for(i=1; i<=l; i++) {
- int aKey;
-
- theStream.getline(aValueString,aSize,'\n');
- aValue = aValueString;
- aKey = atoi(aValue.c_str());
- if (aValue[0] == '0')
+ aStr = v[pos++]; //Ket as a string
+ int aKey = strtol(aStr.c_str(), NULL, 10);
+ string aValue;
+ if(aStr[0] == '0') //If the first character of the key is 0, then empty value
aValue = "";
else {
- unsigned long aValueSize;
- theStream >> aValueSize;
- theStream.read(aValueString, 1); // an '\n' omitting
- theStream.read(aValueString, aValueSize);
- theStream.read(aValueString, 1); // an '\n' omitting
- aValue = aValueString;
+ long aSize = strtol(v[pos++].c_str(), NULL, 10);
+ aValue = v[pos++];
}
myTable[aKey] = aValue;
}
- delete(aValueString);
}