mirror of
https://github.com/nasa/trick.git
synced 2024-12-24 07:16:41 +00:00
Change std::endl to linefeed as appropriate. (#773)
* Fix endl issue in variable server JSON generation. Ref #766 * Change std::endl to line feed as appropraite. #766 * Change std::endl to line feed in MemoryManager as appropriate. #766 * Change std::endl to linefeed as appropriate. #766 * Change std::endl to line feed as appropriate in JSONVariableServer. #766 * Change std::endl to line feed as appropriate in still more files. #766
This commit is contained in:
parent
3187dd9012
commit
3f35388b49
@ -116,7 +116,7 @@ void Trick::ClassicCheckPointAgent::write_decl(std::ostream& chkpnt_os, ALLOC_IN
|
||||
|
||||
if ( info->num_index == 0 ) {
|
||||
|
||||
chkpnt_os << type_spec << " " << info->name << ";" << std::endl;
|
||||
chkpnt_os << type_spec << " " << info->name << ";\n";
|
||||
|
||||
} else if ((info->num_index > 0) && (info->num_index <= TRICK_MAX_INDEX)) {
|
||||
int ii;
|
||||
@ -978,7 +978,7 @@ void Trick::ClassicCheckPointAgent::write_rvalue( std::ostream& chkpnt_os, void*
|
||||
|
||||
array_len = attr->index[curr_dim].size ;
|
||||
|
||||
chkpnt_os << std::endl;
|
||||
chkpnt_os << "\n";
|
||||
|
||||
for (ii=0 ; ii < curr_dim+1 ; ii++) {
|
||||
chkpnt_os << " ";
|
||||
@ -993,7 +993,7 @@ void Trick::ClassicCheckPointAgent::write_rvalue( std::ostream& chkpnt_os, void*
|
||||
// Conditionally line-break and indent.
|
||||
if (( (ii+1) % array_elements_per_line[attr->type]) == 0 ) {
|
||||
// Line-break.
|
||||
chkpnt_os << std::endl;
|
||||
chkpnt_os << "\n";
|
||||
// Indent.
|
||||
for (jj=0 ; jj < curr_dim+1 ; jj++) {
|
||||
chkpnt_os << " ";
|
||||
@ -1011,7 +1011,7 @@ void Trick::ClassicCheckPointAgent::write_rvalue( std::ostream& chkpnt_os, void*
|
||||
|
||||
int ii;
|
||||
|
||||
chkpnt_os << std::endl;
|
||||
chkpnt_os << "\n";
|
||||
for (ii=0 ; ii < curr_dim+1 ; ii++) {
|
||||
chkpnt_os << " ";
|
||||
}
|
||||
@ -1024,7 +1024,7 @@ void Trick::ClassicCheckPointAgent::write_rvalue( std::ostream& chkpnt_os, void*
|
||||
write_rvalue( chkpnt_os, address, attr, curr_dim + 1, offset * attr->index[curr_dim].size + ii);
|
||||
}
|
||||
|
||||
chkpnt_os << std::endl;
|
||||
chkpnt_os << "\n";
|
||||
|
||||
for (ii=0 ; ii < curr_dim+1 ; ii++) {
|
||||
chkpnt_os << " " ;
|
||||
|
@ -82,7 +82,7 @@ bool ClassicChkPtAgent:: writeDeclaration( std::ostream& out_s, std::string name
|
||||
bool errorCondition = false;
|
||||
if (dataType != NULL) {
|
||||
out_s << dataType->makeDeclaration(name, true);
|
||||
out_s << ";" << std::endl;
|
||||
out_s << ";\n";
|
||||
} else {
|
||||
errorCondition = true;
|
||||
}
|
||||
@ -98,12 +98,12 @@ bool ClassicChkPtAgent::writeVariable( std::ostream& out_s, MemMgr* memMgr, void
|
||||
std::stringstream rightHandSide;
|
||||
dataType->printValue( rightHandSide, address );
|
||||
writeAssignment( out_s, rightHandSide.str() );
|
||||
out_s << std::endl;
|
||||
out_s << "\n";
|
||||
} else if ( typeClass == TypeClass::POINTER ) {
|
||||
std::stringstream pointerName;
|
||||
errorCondition |= writePointerValue( pointerName, memMgr, address, (const PointerDataType*) dataType);
|
||||
writeAssignment(out_s, pointerName.str());
|
||||
out_s << std::endl;
|
||||
out_s << "\n";
|
||||
} else if ( typeClass == TypeClass::COMPOSITE ) {
|
||||
errorCondition |= writeCompositeAssignments( out_s, memMgr, address, (const CompositeDataType*)dataType);
|
||||
} else if ( typeClass == TypeClass::ARRAY ) {
|
||||
@ -167,7 +167,7 @@ bool ClassicChkPtAgent:: writeArrayAssignments( std::ostream& out_s, MemMgr* mem
|
||||
}
|
||||
rightHandSide << "}";
|
||||
writeAssignment( out_s, rightHandSide.str() );
|
||||
out_s << std::endl;
|
||||
out_s << "\n";
|
||||
} else {
|
||||
for (int ii=0; ii < elementCount; ii++) {
|
||||
void * elementAddress = (char*) address + (ii * elementTypeSize );
|
||||
@ -200,7 +200,7 @@ bool ClassicChkPtAgent::writeCompositeAssignments( std::ostream& out_s, MemMgr*
|
||||
std::stringstream rightHandSide;
|
||||
structMember->printValue( rightHandSide, address );
|
||||
writeAssignment( out_s, rightHandSide.str() );
|
||||
out_s << std::endl;
|
||||
out_s << "\n";
|
||||
} else {
|
||||
char* memberAddress;
|
||||
const DataType* memberDataType;
|
||||
|
@ -216,12 +216,12 @@ void CompositeDataType::printValue(std::ostream &s, void *address) const {
|
||||
std::string CompositeDataType::toString() const {
|
||||
std::stringstream ss;
|
||||
int memberCount = memberList.size() ;
|
||||
ss << "composite {" << std::endl;
|
||||
ss << "composite {\n";
|
||||
for (int ii=0; ii < memberCount ; ii++) {
|
||||
ss << memberList[ii]->toString();
|
||||
ss << ";" << std::endl;
|
||||
ss << ";\n";
|
||||
}
|
||||
ss << "}" << std::endl;
|
||||
ss << "}\n";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -161,14 +161,14 @@ void EnumDataType::printValue(std::ostream &s, void *address) const {
|
||||
std::string EnumDataType::toString() const {
|
||||
std::stringstream ss;
|
||||
int enum_count = enum_list.size() ;
|
||||
ss << "enum {" << std::endl;
|
||||
ss << "enum {\n";
|
||||
for (int ii=0; ii < enum_count ; ii++) {
|
||||
if (ii) {
|
||||
ss << "," << std::endl;
|
||||
ss << ",\n";
|
||||
}
|
||||
ss << enum_list[ii]->toString();
|
||||
}
|
||||
ss << "}" << std::endl;
|
||||
ss << "}\n";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -183,10 +183,10 @@ int Trick::JSONVariableServer::restart() {
|
||||
}
|
||||
|
||||
void Trick::JSONVariableServer::dump( std::ostream & oss ) {
|
||||
oss << "Trick::JSONVariableServer (" << name << ")" << std::endl ;
|
||||
oss << " enabled = " << enabled << std::endl ;
|
||||
oss << " source_address = " << source_address << std::endl ;
|
||||
oss << " port = " << port << std::endl ;
|
||||
oss << "Trick::JSONVariableServer (" << name << ")\n";
|
||||
oss << " enabled = " << enabled << "\n";
|
||||
oss << " source_address = " << source_address << "\n";
|
||||
oss << " port = " << port << "\n";
|
||||
oss << " user_port_requested = " << user_port_requested << std::endl ;
|
||||
Trick::ThreadBase::dump(oss) ;
|
||||
}
|
||||
|
@ -2,30 +2,30 @@
|
||||
#include "trick/MemoryManager.hh"
|
||||
|
||||
void Trick::MemoryManager::write_JSON_alloc_info(std::ostream& s, ALLOC_INFO *alloc_info) {
|
||||
s << "{" << std::endl;
|
||||
s << "{\n";
|
||||
if (!alloc_info->name) {
|
||||
s << "\"name\":null," << std::endl;
|
||||
s << "\"name\":null,\n";
|
||||
} else {
|
||||
s << "\"name\":\"" << alloc_info->name << "\"," << std::endl;
|
||||
s << "\"name\":\"" << alloc_info->name << "\",\n";
|
||||
}
|
||||
s << "\"start\":\"" << alloc_info->start << "\"," << std::endl;
|
||||
s << "\"end\":\"" << alloc_info->end << "\"," << std::endl;
|
||||
s << "\"num\":\"" << alloc_info->num << "\"," << std::endl;
|
||||
s << "\"size\":\"" << alloc_info->size << "\"," << std::endl;
|
||||
s << "\"type\":\"" << trickTypeCharString(alloc_info->type, alloc_info->user_type_name) << "\"," << std::endl;
|
||||
s << "\"start\":\"" << alloc_info->start << "\",\n";
|
||||
s << "\"end\":\"" << alloc_info->end << "\",\n";
|
||||
s << "\"num\":\"" << alloc_info->num << "\",\n";
|
||||
s << "\"size\":\"" << alloc_info->size << "\",\n";
|
||||
s << "\"type\":\"" << trickTypeCharString(alloc_info->type, alloc_info->user_type_name) << "\",\n";
|
||||
s << "\"stcl\":" ;
|
||||
if (alloc_info->stcl == TRICK_LOCAL) {
|
||||
s << "\"TRICK_LOCAL\"," << std::endl;
|
||||
s << "\"TRICK_LOCAL\",\n";
|
||||
}
|
||||
if (alloc_info->stcl == TRICK_EXTERN) {
|
||||
s << "\"TRICK_EXTERN\"," << std::endl;
|
||||
s << "\"TRICK_EXTERN\",\n";
|
||||
}
|
||||
s << "\"language\":";
|
||||
if (alloc_info->language == Language_C ) {
|
||||
s << "\"Language_C\"," << std::endl;
|
||||
s << "\"Language_C\",\n";
|
||||
}
|
||||
if (alloc_info->language == Language_CPP) {
|
||||
s << "\"Language_CPP\"," << std::endl;
|
||||
s << "\"Language_CPP\",\n";
|
||||
}
|
||||
s << "\"index\": [" ;
|
||||
for (int ii=0; ii<alloc_info->num_index; ii++) {
|
||||
@ -34,7 +34,7 @@ void Trick::MemoryManager::write_JSON_alloc_info(std::ostream& s, ALLOC_INFO *al
|
||||
}
|
||||
s << alloc_info->index[ii] ;
|
||||
}
|
||||
s << "]}" ;
|
||||
s << "]}" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@ -44,18 +44,18 @@ void Trick::MemoryManager::write_JSON_alloc_list(std::ostream& s, int chunk_star
|
||||
ALLOC_INFO* alloc_info;
|
||||
|
||||
int size = alloc_info_map.size();
|
||||
s << "{" << std::endl;
|
||||
s << "\"alloc_total\":" << size << "," << std::endl;
|
||||
s << "\"chunk_size\":" << chunk_size << "," << std::endl;
|
||||
s << "\"chunk_start\":" << chunk_start << "," << std::endl;
|
||||
s << "\"alloc_list\":[" << std::endl;
|
||||
s << "{\n";
|
||||
s << "\"alloc_total\":" << size << ",\n";
|
||||
s << "\"chunk_size\":" << chunk_size << ",\n";
|
||||
s << "\"chunk_start\":" << chunk_start << ",\n";
|
||||
s << "\"alloc_list\":[\n";
|
||||
pos = alloc_info_map.begin();
|
||||
std::advance(pos, chunk_start);
|
||||
|
||||
for (int count = 0; count < chunk_size && pos!=alloc_info_map.end() ; pos++, count++) {
|
||||
alloc_info = pos->second;
|
||||
if (count != 0) {
|
||||
s << "," << std::endl;
|
||||
s << ",\n";
|
||||
}
|
||||
write_JSON_alloc_info(s, alloc_info);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ void * Trick::MessageTCDeviceListenThread::thread_body() {
|
||||
}
|
||||
|
||||
void Trick::MessageTCDeviceListenThread::dump( std::ostream & oss ) {
|
||||
oss << "Trick::MessageTCDeviceListenThread (" << name << ")" << std::endl ;
|
||||
oss << "Trick::MessageTCDeviceListenThread (" << name << ")\n";
|
||||
oss << " port = " << get_port() << std::endl ;
|
||||
Trick::ThreadBase::dump(oss) ;
|
||||
}
|
||||
|
@ -26,15 +26,15 @@ void Trick::MonteCarlo::dryrun() {
|
||||
of.open(std::string(buffer_stream.str() + "/monte_input").c_str()) ;
|
||||
of << "# This run can be executed in stand alone (non-Monte Carlo) mode by running\n"
|
||||
"# the S_main executable with this file specified as the input file.\n\n" ;
|
||||
of << "if (sys.version_info > (3, 0)):" << std::endl ;
|
||||
of << " exec(open(\"" << command_line_args_get_input_file() << "\").read())" << std::endl ;
|
||||
of << "else:" << std::endl ;
|
||||
of << " execfile(\"" << command_line_args_get_input_file() << "\")" << std::endl << std::endl ;
|
||||
of << "trick.mc_set_enabled(0)" << std::endl ;
|
||||
of << "if (sys.version_info > (3, 0)):\n";
|
||||
of << " exec(open(\"" << command_line_args_get_input_file() << "\").read())\n";
|
||||
of << "else:\n";
|
||||
of << " execfile(\"" << command_line_args_get_input_file() << "\")\n\n";
|
||||
of << "trick.mc_set_enabled(0)\n";
|
||||
for (std::vector<std::string>::size_type j = 0; j < curr_run->variables.size(); ++j) {
|
||||
of << curr_run->variables[j] << std::endl ;
|
||||
of << curr_run->variables[j] << "\n";
|
||||
}
|
||||
of << "trick.set_output_dir(\"" << buffer_stream.str() << "\")" << std::endl ;
|
||||
of << "trick.set_output_dir(\"" << buffer_stream.str() << "\")\n";
|
||||
of << "trick.mc_set_current_run(" << curr_run->id << ")" << std::endl ;
|
||||
of.close() ;
|
||||
}
|
||||
|
@ -322,10 +322,10 @@ void * Trick::ThreadBase::thread_helper( void * context ) {
|
||||
}
|
||||
|
||||
void Trick::ThreadBase::dump( std::ostream & oss ) {
|
||||
oss << " from Trick::ThreadBase" << std::endl ;
|
||||
oss << " pthread_id = " << pthread_id << std::endl ;
|
||||
oss << " process_id = " << pid << std::endl ;
|
||||
oss << " rt_priority = " << rt_priority << std::endl ;
|
||||
oss << " from Trick::ThreadBase\n";
|
||||
oss << " pthread_id = " << pthread_id << "\n";
|
||||
oss << " process_id = " << pid << "\n";
|
||||
oss << " rt_priority = " << rt_priority << "\n";
|
||||
#if __linux
|
||||
oss << " cpus = " ;
|
||||
bool first_print = true ;
|
||||
|
@ -21,17 +21,17 @@ Trick::VariableServer::~VariableServer() {
|
||||
std::ostream& Trick::operator<< (std::ostream& s, Trick::VariableServer& vs) {
|
||||
std::map < pthread_t , VariableServerThread * >::iterator it ;
|
||||
|
||||
s << "{\"variable_server_connections\":[" << std::endl;
|
||||
s << "{\"variable_server_connections\":[\n";
|
||||
int count = 0;
|
||||
int n_connections = (int)vs.var_server_threads.size();
|
||||
for ( it = vs.var_server_threads.begin() ; it != vs.var_server_threads.end() ; it++ ) {
|
||||
s << "{" << std::endl;
|
||||
s << "{\n";
|
||||
s << *(*it).second;
|
||||
s << "}";
|
||||
if ((n_connections-count)>1) {
|
||||
s << "," ;
|
||||
}
|
||||
s << std::endl;
|
||||
s << "\n";
|
||||
count ++;
|
||||
}
|
||||
s << "]}" << std::endl;
|
||||
|
@ -67,33 +67,34 @@ Trick::VariableServerThread::~VariableServerThread() {
|
||||
|
||||
std::ostream& Trick::operator<< (std::ostream& s, Trick::VariableServerThread& vst) {
|
||||
|
||||
// Write a JSON representation of a Trick::VariableServerThread to an ostream.
|
||||
|
||||
std::vector <Trick::VariableReference *>::iterator it;
|
||||
|
||||
struct sockaddr_in otherside;
|
||||
socklen_t len = (socklen_t)sizeof(otherside);
|
||||
|
||||
s << " \"connection\":{" << std::endl;
|
||||
s << " \"client_tag\":\"" << vst.connection.client_tag << "\"," << std::endl;
|
||||
s << " \"connection\":{\n";
|
||||
s << " \"client_tag\":\"" << vst.connection.client_tag << "\",\n";
|
||||
|
||||
int err = getpeername(vst.connection.socket, (struct sockaddr*)&otherside, &len);
|
||||
|
||||
if (err == 0) {
|
||||
s << " \"client_IP_address\":\"" << inet_ntoa(otherside.sin_addr) << "\"," << std::endl;
|
||||
s << " \"client_port\":\"" << ntohs(otherside.sin_port) << "\"," << std::endl;
|
||||
s << " \"client_IP_address\":\"" << inet_ntoa(otherside.sin_addr) << "\",\n";
|
||||
s << " \"client_port\":\"" << ntohs(otherside.sin_port) << "\",\n";
|
||||
} else {
|
||||
s << " \"client_IP_address\":\"unknown\"," << std::endl;
|
||||
s << " \"client_port\":\"unknown\"," << std::endl;
|
||||
s << " \"client_IP_address\":\"unknown\",\n";
|
||||
s << " \"client_port\":\"unknown\",";
|
||||
}
|
||||
|
||||
if (vst.binary_data) {
|
||||
s << " \"format\":\"BINARY\",";
|
||||
s << " \"format\":\"BINARY\",\n";
|
||||
} else {
|
||||
s << " \"format\":\"ASCII\",";
|
||||
s << " \"format\":\"ASCII\",\n";
|
||||
}
|
||||
s << std::endl;
|
||||
s << " \"update_rate\":" << vst.update_rate << "," << std::endl;
|
||||
s << " \"update_rate\":" << vst.update_rate << ",\n";
|
||||
|
||||
s << " \"variables\":[" << std::endl;
|
||||
s << " \"variables\":[\n";
|
||||
|
||||
int n_vars = (int)vst.vars.size();
|
||||
for (int i=0 ; i<n_vars ; i++) {
|
||||
@ -101,9 +102,9 @@ std::ostream& Trick::operator<< (std::ostream& s, Trick::VariableServerThread& v
|
||||
if ((n_vars-i)>1) {
|
||||
s << "," ;
|
||||
}
|
||||
s << std::endl;
|
||||
s << "\n";
|
||||
}
|
||||
s << " ]" << std::endl;
|
||||
s << " ]\n";
|
||||
s << " }" << std::endl;
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user