MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / open

Method open

SRC/handler/XmlFileStream.cpp:176–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176int
177XmlFileStream::open(void)
178{
179 // check setFile has been called
180 if (fileName == 0) {
181 std::cerr << "XmlFileStream::open(void) - no file name has been set\n";
182 return -1;
183 }
184
185 // if file already open, return
186 if (fileOpen == 1) {
187 return 0;
188 }
189
190 if (sendSelfCount > 0) {
191 strcat(fileName,".0");
192 }
193
194 // open file
195 if (theOpenMode == OVERWRITE)
196 theFile.open(fileName, ios::out);
197 else
198 theFile.open(fileName, ios::out| ios::app);
199
200 theOpenMode = APPEND;
201
202 if (theFile.bad()) {
203 std::cerr << "WARNING - XmlFileStream::open()";
204 std::cerr << " - could not open file " << fileName << std::endl;
205 fileOpen = 0;
206 return -1;
207 } else
208 fileOpen = 1;
209
210
211 if (sendSelfCount >= 0) {
212
213 theFile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
214 theFile << " <OpenSees\n";
215 theFile << " xmlns:xsi = \"http://www.w3.org/2001/XMLSchema-instance\"\n";
216 theFile << " xsi:noNamespaceSchemaLocation = \"http://OpenSees.berkeley.edu/xml-schema/xmlns/OpenSees.xsd\">\n";
217 numIndent++;
218
219 }
220
221 theFile << std::setprecision(filePrecision);
222
223 // theFile << setiosflags(ios::fixed);
224
225 return 0;
226}
227
228int
229XmlFileStream::close(void)

Callers 7

setFloatFieldMethod · 0.95
tagMethod · 0.95
attrMethod · 0.95
writeMethod · 0.95
setOrderMethod · 0.95
XmlFileStream.cppFile · 0.45
mergeXMLMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected