void SymConst::printScalar(int d, string scalarName, string value) { Symbol::PrintSymbol(d); printPart(scalarName, TYPE_LEN); printPart(value, VALUE_LEN); printPart("", COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); }
void SymTypeSubrange::PrintSymbol(int d) { Symbol::PrintSymbol(d); printPart("subrange", TYPE_LEN); printPart("", VALUE_LEN); printPart(getTypeValue(), COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); }
void SymType::PrintSymbol(int d) { Symbol::PrintSymbol(d); printPart("type", TYPE_LEN); printPart("", VALUE_LEN); printPart("", COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); }
void SymTypeArry::PrintSymbol(int d) { Symbol::PrintSymbol(d); printPart("array", TYPE_LEN); //printPart(dynamic_cast<SymTypeSubrange*>(subrange)->getSubrangeStr(), VALUE_LEN); printPart("ar", VALUE_LEN); printPart(elemType->name, COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); }
void SymVarGlobal::PrintSymbol(int d) { Symbol::PrintSymbol(d); printPart("variable", TYPE_LEN); printPart("", VALUE_LEN); printPart(type->getTypeValue(), COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); type->PrintType(d); }
void SymTypeAlias::PrintSymbol(int d) { Symbol::PrintSymbol(d); printPart("type alias", TYPE_LEN); string name = *refType != stTypeInteger && *refType != stTypeFloat && *refType != stTypeChar && *refType != stTypeRecord ? refType->name : ""; printPart(name, VALUE_LEN); printPart(refType->getTypeValue(), COLUMN_LEN); printPart(to_string(d), TABLE_IDX_LEN); refType->PrintType(d); }
/** * This Method will make automatic line breaks into the text. * @param output The text. * @return Formatted line. If the line does not need any line breaks "" will be returned. */ std::string GameManager::printPart(std::string output) { if(getLength(output) > 68) { //Split into words: std::vector<std::string> result; std::stringstream stream(output); // Turn the string into a stream. std::string temp; while(std::getline(stream, temp, ' ')) { result.push_back(temp); } std::vector<std::string> parsedLine = result; //put words together to one line: std::string line; for(int i = 0; i <= parsedLine.size() && getLength(line) + getLength(parsedLine.at(i)) < 68; i++) { line += parsedLine.at(i) + std::string(" "); } line += "\n"; _output += line; std::string(printPart(output.substr(getLength(line) - 2, getLength(output) - getLength(line) + getLength(parsedLine.at(parsedLine.size() - 1))))); return line; } else { _output += output; } return ""; }
int main( int argc, char * argv[] ) { if( argc < 2 ) { printf( "Usage: %s <eml> [charset]\n", argv[0] ); exit( 0 ); } const char * charset = NULL; if( argc > 2 ) charset = argv[2]; const char * filename = argv[1]; SP_MimeBuffer buffer; if( 0 != SP_MimeUtils::readFile( filename, &buffer ) ) { printf( "cannot not read %s\n", filename ); exit( -1 ); } SP_MimeLiteParser parser; parser.parse( buffer.getBuffer(), buffer.getWritePos() ); if( NULL != charset ) { printDecodedPart( parser.getRootPart(), charset ); } else { printPart( parser.getRootPart() ); } return 0; }
/** * Puts a text into the buffer and does automatic line breaks. This does not work with formatting stuff like \033[31m stuff and so on. * This method cuts the text by the '\n' character and calls the printPart() method for each part. * @param output The text. */ void GameManager::printText(std::string output) { if(std::count(_output.begin(), _output.end(), '\n') != 0) { //Split into lines: std::vector<std::string> result; std::stringstream stream(output); // Turn the string into a stream. std::string temp; while(std::getline(stream, temp, '\n')) { result.push_back(temp); } std::vector<std::string> parsedLine = result; for(int i = 0; i < parsedLine.size(); i++) { printPart(parsedLine.at(i)); _output += std::string("\n"); } } else { _output += output; } }
void printDecodedPart( const SP_MimePart * part, const char * destCharset ) { SP_MimePart decodePart; SP_MimeCodec::decodePart( part, destCharset, &decodePart ); printPart( &decodePart ); printf( "\n\nGetShow\n\n" ); SP_MimeBuffer text; SP_MimePartUtils::getTextMessage( &decodePart, &text ); if( NULL != text.getBuffer() ) printf( "%s\n", text.getBuffer() ); printf( "\n\nAttachments\n\n" ); SP_MimePartVector attachmentList; SP_MimePartUtils::getAttachmentList( &decodePart, &attachmentList ); for( int i = 0; i < (int)attachmentList.size(); ++i ) { SP_MimePart * part = attachmentList[ i ]; const SP_MimeHeader * header = part->getHeaderList()->find( "Content-Disposition" ); char filename[ 256 ] = { 0 }; if( NULL != header ) { if( 0 == header->getParam( "filename", filename, sizeof( filename ) ) ) { printf( "%d: %s\n", i, filename ); } else { printf( "%d: %s\n", i, header->getValue() ); } } } }
void ewol::compositing::Sprite::printSprite(const ivec2& _spriteID, const vec3& _size) { if( _spriteID.x()<0 || _spriteID.y()<0 || _spriteID.x() >= m_nbSprite.x() || _spriteID.y() >= m_nbSprite.y()) { return; } printPart(vec2(_size.x(),_size.y()), vec2((float)(_spriteID.x() )*m_unitarySpriteSize.x(), (float)(_spriteID.y() )*m_unitarySpriteSize.y()), vec2((float)(_spriteID.x()+1)*m_unitarySpriteSize.x(), (float)(_spriteID.y()+1)*m_unitarySpriteSize.y())); }
// ------------------------------------------------------------------------ static void testPartition( Part pt ) { char c; int n; int x, y, xroot, yroot, newroot; int ch; for (;;) { printf( "Command: "); n = scanf( " %c", &c ); if (n==EOF) break; if (c=='.') break; switch (c) { case 'u': n = scanf( "%i%i", &x, &y); if (n!=2) break; if (x<0 || x >= SIZE || y<0 || y >= SIZE) break; xroot = findPart( pt, x ); yroot = findPart( pt, y ); newroot = unionPart( pt, xroot, yroot ); printf( "Union has block id %i\n", newroot ); break; case 'f': n = scanf( "%i", &x ); if (n!=1) break; if (x<0 || x >= SIZE) break; xroot = findPart( pt, x ); printf( "%i is in block %i\n", x, xroot ); break; case 'p': printPart( pt ); break; default: printf( "Unknown command '%c'\n", c); } // skip remainder of line do { ch = getchar(); if (ch == EOF) break; } while( ch != '\n' ); } }
void printPart( const SP_MimePart * part ) { SP_MimeHeaderList * headerList = part->getHeaderList(); SP_MimePartList * partList = part->getBodyPartList(); for( int i = 0; i < headerList->getCount(); i++ ) { const SP_MimeHeader * header = headerList->getItem( i ); if( NULL == strstr( header->getName(), "HMM" ) ) { printf( "%s: %s\r\n", header->getName(), header->getValue() ); } else { printf( "%s:%s\r\n", header->getName(), header->getValue() ); } } printf( "\r\n" ); char boundary[ 256 ] = { 0 }; headerList->getBoundary( boundary, sizeof( boundary ) ); if( part->getContent()->getWritePos() > 0 ) { printf( "%s", part->getContent()->getBuffer() ); } if( part->getPreamble()->getWritePos() > 0 ) { printf( "%s", part->getPreamble()->getBuffer() ); } for( int i = 0; i < partList->getCount(); i++ ) { printf( "\r\n--%s\r\n", boundary ); printPart( partList->getItem( i ) ); } if( partList->getCount() > 0 ) { printf( "\r\n--%s--\r\n", boundary ); } if( part->getEpilogue()->getWritePos() > 0 ) { printf( "%s", part->getEpilogue()->getBuffer() ); } }
void Symbol::PrintSymbol(int d) { printPart(name, NAME_LEN); }
int main(int argc, char **argv) { struct part *part; int opt, n; int dump_part = 0; int printStructurePotentialEnergy = 0; int needVDW = 1; char *printPotential = NULL; double printPotentialInitial = -1; // pm double printPotentialIncrement = -1; // pm double printPotentialLimit = -1; // pm char *fileNameTemplate = NULL; char *outputFilename = NULL; reinit_globals(); if (signal(SIGTERM, &SIGTERMhandler) == SIG_ERR) { perror("signal(SIGTERM)"); exit(1); } CommandLine = assembleCommandLine(argc, argv); while ((opt = getopt_long(argc, argv, "hnmEi:f:s:t:xXONI:K:rD:o:q:B:", option_vec, NULL)) != -1) { switch(opt) { case 'h': usage(); case OPT_DUMP_PART: dump_part = 1; break; case OPT_WRITE_GROMACS_TOPOLOGY: GromacsOutputBaseName = optarg; break; case OPT_PATH_TO_CPP: PathToCpp = optarg; break; case OPT_SYSTEM_PARAMETERS: SystemParametersFileName = optarg; break; case OPT_PRINT_POTENTIAL: printPotential = optarg; break; case OPT_INITIAL: printPotentialInitial = atof(optarg); break; case OPT_INCREMENT: printPotentialIncrement = atof(optarg); break; case OPT_LIMIT: printPotentialLimit = atof(optarg); break; case OPT_DIRECT_EVALUATE: DirectEvaluate = 1; break; case OPT_INTERPOLATE: DirectEvaluate = 0; break; case OPT_SIMPLE_MOVIE_FORCE_SCALE: SimpleMovieForceScale = atof(optarg); break; case OPT_MIN_THRESH_CUT_RMS: MinimizeThresholdCutoverRMS = atof(optarg); break; case OPT_MIN_THRESH_CUT_MAX: MinimizeThresholdCutoverMax = atof(optarg); break; case OPT_MIN_THRESH_END_RMS: MinimizeThresholdEndRMS = atof(optarg); break; case OPT_MIN_THRESH_END_MAX: MinimizeThresholdEndMax = atof(optarg); break; case OPT_VDW_CUTOFF_RADIUS: VanDerWaalsCutoffRadius = atof(optarg); break; case OPT_VDW_CUTOFF_FACTOR: VanDerWaalsCutoffFactor = atof(optarg); break; case OPT_ENABLE_ELECTROSTATIC: EnableElectrostatic = atoi(optarg); break; case OPT_TIME_REVERSAL: TimeReversal = 1; break; case OPT_THERMOSTAT_GAMMA: ThermostatGamma = atof(optarg); break; case OPT_PRINT_ENERGIES: PrintPotentialEnergy = 1; break; case OPT_NEIGHBOR_SEARCHING: NeighborSearching = atoi(optarg); break; case 'n': // ignored break; case 'm': ToMinimize=1; break; case 'E': printStructurePotentialEnergy=1; break; case 'i': IterPerFrame = atoi(optarg); break; case 'f': NumFrames = atoi(optarg); break; case 's': Dt = atof(optarg); break; case 't': Temperature = atof(optarg); break; case 'x': DumpAsText = 1; break; case 'X': DumpIntermediateText = 1; break; case 'O': OutputFormat = 1; break; case 'N': OutputFormat = 2; break; case OPT_OUTPUT_FORMAT_3: OutputFormat = 3; break; case 'I': IDKey = optarg; break; case 'K': KeyRecordInterval = atoi(optarg); break; case 'r': PrintFrameNums = 1; break; case 'D': n = atoi(optarg); if (n < 32 && n >= 0) { debug_flags |= 1 << n; } break; case 'o': outputFilename = optarg; break; case 'q': TraceFileName = optarg; break; case 'B': BaseFileName = optarg; break; case ':': case '?': default: usage(); exit(1); } } if (optind + 1 == argc) { // (optind < argc) if not paranoid fileNameTemplate = argv[optind]; } if (DEBUG(D_PRINT_BEND_STRETCH)) { // -D8 initializeBondTable(); printBendStretch(); exit(0); } if (DumpAsText) { OutputFormat = 0; } if (!fileNameTemplate) { usage(); } InputFileName = replaceExtension(fileNameTemplate, "mmp"); if (BaseFileName != NULL) { int i1; int i2; struct xyz *basePositions; struct xyz *initialPositions; basePositions = readXYZ(BaseFileName, &i1); if (basePositions == NULL) { fprintf(stderr, "could not read base positions file from -B<filename>\n"); exit(1); } initialPositions = readXYZ(InputFileName, &i2); if (initialPositions == NULL) { fprintf(stderr, "could not read comparison positions file\n"); exit(1); } if (i1 != i2) { fprintf(stderr, "structures to compare must have same number of atoms\n"); exit(1); } exit(doStructureCompare(i1, basePositions, initialPositions, NumFrames, 1e-8, 1e-4, 1.0+1e-4)); } if (outputFilename) { OutputFileName = copy_string(outputFilename); } else { char *extension; switch (OutputFormat) { case 0: extension = "xyz"; break; case 1: case 2: default: extension = "dpb"; break; case 3: extension = "gro"; break; } OutputFileName = replaceExtension(fileNameTemplate, extension); } if (TraceFileName) { TraceFile = fopen(TraceFileName, "w"); if (TraceFile == NULL) { perror(TraceFileName); exit(1); } } else { TraceFile = fdopen(1, "w"); if (TraceFile == NULL) { perror("fdopen stdout as TraceFile"); exit(1); } } traceFileVersion(); // call this before any other writes to trace file. // tell where and how the simulator was built. We never build the // standalone simulator with distutils. fprintf(TraceFile, "%s", tracePrefix); initializeBondTable(); if (IterPerFrame <= 0) IterPerFrame = 1; if (printPotential) { printPotentialAndGradientFunctions(printPotential, printPotentialInitial, printPotentialIncrement, printPotentialLimit); exit(0); } part = readMMP(InputFileName); if (EXCEPTION) { exit(1); } if (GromacsOutputBaseName != NULL) { needVDW = 0; } initializePart(part, needVDW); createPatterns(); matchPartToAllPatterns(part); if (printStructurePotentialEnergy) { struct xyz *force = (struct xyz *)allocate(sizeof(struct xyz) * part->num_atoms); double potentialEnergy = calculatePotential(part, part->positions); calculateGradient(part, part->positions, force); printf("%e %e %e %e (Potential energy in aJ, gradient of atom 1)\n", potentialEnergy, force[1].x, force[1].y, force[1].z); exit(0); } if (dump_part) { // // this segment is convenient to run valgrind on to test the // part and bond table destructors. By the time we reach the // exit() there should be no malloc'd blocks remaining. // // valgrind -v --leak-check=full --leak-resolution=high --show-reachable=yes simulator --dump-part part.mmp // printPart(stdout, part); destroyPart(part); part = NULL; destroyBondTable(); fclose(TraceFile); destroyAccumulator(CommandLine); free(InputFileName); free(OutputFileName); exit(0); } if (GromacsOutputBaseName != NULL) { printGromacsToplogy(GromacsOutputBaseName, part); destroyPart(part); part = NULL; destroyBondTable(); fclose(TraceFile); destroyAccumulator(CommandLine); free(InputFileName); free(OutputFileName); done(""); exit(0); } constrainGlobals(); traceHeader(part); if (ToMinimize) { NumFrames = max(NumFrames,(int)sqrt((double)part->num_atoms)); Temperature = 0.0; } else { traceJigHeader(part); } OutputFile = fopen(OutputFileName, DumpAsText ? "w" : "wb"); if (OutputFile == NULL) { perror(OutputFileName); exit(1); } writeOutputHeader(OutputFile, part); if (ToMinimize) { minimizeStructure(part); exit(0); } else { dynamicsMovie(part); } done(""); return 0; }
void ewol::compositing::Image::print(const vec2& _size) { printPart(_size, vec2(0,0), vec2(1.0,1.0)); }