void printBodies(const Body* bs, int n) { int i; for (i = 0; i < n; ++i) printBody(&bs[i]); }
string CodeGenerator::generateStringFromFile(const string &inFileName) { in = new ifstream (inFileName.c_str()); out = new ostringstream (); if ( in->fail() || out->fail()) { return ""; } if (! fragmentOutput) { *out << getHeader(); } printBody(); if (! fragmentOutput) { *out << getFooter(); } string result = static_cast<ostringstream*>(out)->str(); delete out; out=NULL; delete in; in=NULL; return result; }
ParseError CodeGenerator::generateFile (const string &inFileName, const string &outFileName) { ParseError error=PARSE_OK; in = (inFileName.empty()? &cin :new ifstream (inFileName.c_str())); if (!in->fail() && error==PARSE_OK) { out = (outFileName.empty()? &cout :new ofstream (outFileName.c_str())); if ( out->fail()) { error=BAD_OUTPUT; } } if ( in->fail()) { error=BAD_INPUT; } if (error==PARSE_OK) { if (! fragmentOutput) { *out << getHeader(); } printBody(); if (! fragmentOutput) { *out << getFooter(); } } if (!outFileName.empty()) { delete out; out=NULL; } if (!inFileName.empty()) { delete in; in=NULL; } return error; }
void CReport::output(const Activity & activity) { switch (activity) { case COutputInterface::BEFORE: printHeader(); break; case COutputInterface::DURING: printBody(); break; case COutputInterface::AFTER: printFooter(); break; } }
void printTreeRec(cellptr cell, int level) { int i, l; nodeptr q; for (i = 0; i < NCHILD; i++) { if ((q = Child(cell)[i]) != NULL) { if (Type(q) == BODY) { for (l = 1; l < level; l++) printf(" "); printf("%d B ", findIndex((bodyptr) q, cell)); printBody((bodyptr) q); printf("\n"); } else { for (l = 1; l < level; l++) printf(" "); printf("%d C ", findIndex((bodyptr) q, cell)); printCell((cellptr) q); printf("\n"); printTreeRec((cellptr) q, level + 1); } } } }
int main(const int argc, char * const *argv) { dtm_st dtm; time_t t; DT T, e; DT v_e[3], v_g[3]; sexangle_st ang; if (argc!=2) { printUsage(); return EXIT_FAILURE; } s_datadir = argv[1]; t = time(NULL); gmtime_r(&t, &dtm.tm); dtm.sec = 0.; T = amsp_date_tm2julian(&dtm); e = amsp_coord_earthEclipticAtDate(T); printf("Earth ecliptic: %f ", e); amsp_angle_deg2sex(&ang, e*CRG); amsp_angle_sexprint(&ang); printf("\n"); if (vsop87_getCoords(v_e, s_datadir, VSOP87_HELIO_RECT_DATE, BODY_EARTH, T)!=0) return EXIT_FAILURE; printf("Earth heliocentric:\t"); printVect(v_e); printf(" geocentric:\t"); VECT3_DIFF(v_g, v_e, v_e); printVect(v_g); printBody(BODY_MERCURY, "Mercury", T, v_e, e); printBody(BODY_VENUS, "Venus", T, v_e, e); printBody(BODY_MARS, "Mars", T, v_e, e); printBody(BODY_JUPITER, "Jupiter", T, v_e, e); printBody(BODY_SATURN, "Saturn", T, v_e, e); printBody(BODY_URANUS, "Uranus", T, v_e, e); vsop87_clearDataCache(); return 0; }
// // printObject // void wb_print_wbl::printObject(wb_volume& v, wb_object& o, bool recursive) { wb_object to = o; wb_object templ; cdh_uObjid uid; unsigned int idx; wb_cdef cdef = v.cdef(o); if ( !cdef) { m_os << "! %WBDUMP-E-Error Failed to get object class" << endl; m_errCnt++; // return; cdef = v.cdef( pwr_eClass_ClassLost); } const char* cname = cdef.name(); char *block; int size; if ( o.docBlock( &block, &size) && strcmp( block, "") != 0) { indent(0) << "!/**" << endl; indent(0) << "! "; for ( char *s = block; *s; s++) { if ( *s == '\n') { m_os << *s; indent(0) << "! "; continue; } m_os << *s; } m_os << endl; indent(0) << "!*/" << endl; } indent(1) << "Object " << o.name() << " " << cname; if (m_idxFlag) { switch (cdef.cid()) { case pwr_eClass_ClassDef: uid.pwr = o.oid(); idx = uid.c.cix; break; case pwr_eClass_TypeDef: uid.pwr = o.oid(); idx = uid.t.tix; break; case pwr_eClass_ObjBodyDef: uid.pwr = o.oid(); idx = uid.c.bix; break; case pwr_eClass_Param: case pwr_eClass_Input: case pwr_eClass_Output: case pwr_eClass_Intern: case pwr_eClass_Buffer: case pwr_eClass_ObjXRef: uid.pwr = o.oid(); idx = uid.c.aix; break; default: idx = (unsigned long) o.oix(); } m_os << " " << idx; } if ( m_timeFlag) { // Get oh time char timestr[40]; pwr_tTime ohtime = o.ohTime(); time_AtoAscii( &ohtime, time_eFormat_DateAndTime, timestr, sizeof(timestr)); m_os << " " << timestr; } m_os << endl; wb_object co = v.object(cdh_ClassIdToObjid(cdef.cid())); wb_name t("Template"); templ = co.child(t); if (!templ) { m_errCnt++; m_os << "Template not found for class " << cdef.name() << endl; return; } if ( v.cid() == pwr_eClass_ClassVolume && strcmp( o.name(), "Template") == 0) m_isTemplateObject = true; else m_isTemplateObject = false; printBody(v, o, templ, cdef, pwr_eBix_rt); printBody(v, o, templ, cdef, pwr_eBix_dev); if (recursive) { if ( !(m_noFoCodeFlag && isFoCodeObject( v, o))) { for (to = o.first(); to; to = to.after()) printObject(v, to); } } indent(-1) << "EndObject" << endl; }