/home5/piconepr/public_html/isip/projects/speech/software/documentation/class/math/scalar/String/str_04.cc
// file: $isip/class/math/scalar/String/str_04.cc
// version: $Id: str_04.cc 4918 2000-09-20 19:07:44Z duncan $
//
// isip include files
//
#include "String.h"
#include <Sof.h>
#include <SofParser.h>
[snipped]
// method: writeData
//
// arguments:
// Sof& sof: (input) sof file object
// const String& pname: (input) parameter name
//
// return: a boolean value indicating status
//
// this method writes the object to the Sof file. it assumes that the
// Sof file is already positioned correctly.
//
boolean String::writeData(Sof& sof_a, const String& pname_a) const {
// if ascii, read in a line, else binary read
//
if (sof_a.isText()) {
String output;
// start with the assignment string
//
if (pname_a.length() > 0) {
output.assign(pname_a);
output.concat(L" = \"");
}
else {
output.concat(L"\"");
}
// concatenate the value
//
output.concat(*this);
// end with a double quote
//
output.concat(L"\"");
// if a parameter name was set, add a terminator and a newline
//
if (pname_a.length() > 0) {
output.concat(L";\n");
}
// write the text string
//
if (!sof_a.puts(output)) {
return false;
}
}
// binary write, very simple
//
else {
// first write the size
//
long len = length();
if (sof_a.write(&len, sizeof(long), 1) != 1) {
return false;
}
// now write the characters
//
if (len > 0) {
if (!sof_a.puts((*this))) {
return false;
}
}
}
// exit gracefully
//
return true;
}
//
// end of file
Up |
Home |
Courses |
Projects |
Proposals |
Publications
Please direct questions or comments to
joseph.picone@isip.piconepress.com