/** Intro */ void Effects::showIntro(eColors color) { word matrix [16]; renderer.clearScreenBuffer(matrix); for (int j = 0; j < 11; j++) { for (byte i = 0; i < 10; i++) { matrix[i] |= 0b1 << (15 - j); } writeToBuffer(matrix, 5, color); } for (int j = 0; j < 11; j++) { for (int i = 0; i < 10; i++) { matrix[i] ^= 0b1 << (5 + j); } writeToBuffer(matrix, 5, color); } renderer.clearScreenBuffer(matrix); for (int i = 9; i >= 0; i--) { matrix[i] |= 0b1111111111100000; writeToBuffer(matrix, 5, color); } for (int i = 0; i < 10; i++) { matrix[i] ^= 0b1111111111100000; writeToBuffer(matrix, 5, color); } }
void renderOption(COORD c) { writeToBuffer(c, ">>", 0x0A); ifstream option; string text; option.open("option.txt"); c.X = 6; c.Y = 0; while( !option.eof() ) { getline(option, text); writeToBuffer(c, text, 0x0A); c.Y++; } option.close(); c.X = 20; c.Y = 10; writeToBuffer(c, " Change Blocks Shape " , 0x0A); c.X = 20; c.Y = 15; writeToBuffer(c, " Return to Main Menu " , 0x0A); }
Foam::Ostream& Foam::OPstream::writeQuoted(const std::string& str, const bool) { write(char(token::STRING)); size_t len = str.size(); writeToBuffer(len); writeToBuffer(str.c_str(), len + 1, 1); return *this; }
Ostream& OPstream::write(const string& s) { write(char(token::STRING)); size_t ss = s.size(); writeToBuffer(ss); writeToBuffer(s.c_str(), ss + 1, 1); return *this; }
Ostream& OPstream::write(const word& w) { write(char(token::WORD)); size_t ws = w.size(); writeToBuffer(ws); writeToBuffer(w.c_str(), ws + 1, 1); return *this; }
Foam::Ostream& Foam::OPstream::write(const word& str) { write(char(token::WORD)); size_t len = str.size(); writeToBuffer(len); writeToBuffer(str.c_str(), len + 1, 1); return *this; }
void TI2_OnInterrupt(void) { itrCount= itrCount==501?0:++itrCount; int transMode = swPressCount%6; if(itrCount%250 == 0) { if(transMode == 0) TurnOnLEDs(LED_RED); else if(transMode == 1) TurnOnLEDs(LED_YELLOW); else if(transMode == 2) TurnOnLEDs(LED_GREEN); else if(transMode == 3) TurnOnLEDs(LED_CYAN); else if(transMode == 4) TurnOnLEDs(LED_BLUE); else if(transMode == 5) TurnOnLEDs(LED_MAGENTA); } if(isCollectingData()) { writeToBuffer(current_mode); if(itrCount%500 == 0) TurnOnLEDs('x'); } }
/* TODO: We should support non-blocking writes to clients, and buffer data if they don't read it fast enough. If we end up buffering too much data for any particular client then we should disconnect that client. */ static int processSol(fd_set* master, int serverfd, int fdmax, int solFd, bufStore *buf) { char data[SEND_SIZE]; int nbytes; int currFd; nbytes = read(solFd, data, sizeof(data)); if (nbytes > 0) { for (currFd = 0; currFd <= fdmax; currFd++) { if (FD_ISSET(currFd, master)) { if ((currFd != serverfd) && (currFd != solFd)) { if (send(currFd, data, nbytes, 0) == -1) { syslog(LOG_ERR, "mTerm_server: Error on send fd=%d\n", currFd); closeClient(master, currFd); syslog(LOG_ERR, "mTerm_server: Terminated client fd=%d\n", currFd); } } } } writeToBuffer(buf, data, nbytes); } else if (nbytes < 0) { syslog(LOG_ERR, "mTerm_server: Error on read fd=%d\n", solFd); return -1; } return 1; }
ssize_t AudioAACStreamOut::write(const void* buffer, size_t bytes) { Mutex::Autolock _l(mLock); struct timeval end; // check if the stored start time is more than .25sec ago - if so, toss it out gettimeofday(&end, NULL); int diff = end.tv_usec-time.tv_usec+1000000ll*(end.tv_sec-time.tv_sec); if(diff>250000||diff<0) { // 1/4sec ALOGI("Write:: Resetting time; had %d diff\n", diff); gettimeofday(&time, NULL); } //writeToBuffer(bytes/sizeof(unsigned short),(unsigned short*)buffer); // bytes/2 is because I care about shorts, not bytes writeToBuffer(bytes,(unsigned short*)buffer); gettimeofday(&end, NULL); // advance the time time by a frame time.tv_usec += (bytes * 1000000ll) / sizeof(int16_t) / AudioSystem::popCount(channels()) / sampleRate(); if(time.tv_usec>1000000ll) { time.tv_sec++; time.tv_usec-=1000000; } diff = time.tv_usec-end.tv_usec+1000000ll*(time.tv_sec-end.tv_sec); if(diff>0) // If it's positive, sleep the difference between the expected end time and the actual end time usleep(diff); return bytes; }
/*** FUNCTION CODE ***/ int main(int argc, char *argv[]) { //Setup Signal handler and atexit functions signal(SIGINT, INThandler); //Interrupts (calls INThandler) when Ctrl+c (?) COM1 = open_serialport("/dev/ttyUSB0",500000); //Open USB port Time_struct Curr_time; //Create time structure Curr_time = get_time(); //Fill it with current time char fname[26]; //Create space for filename sprintf(fname, "%d-%d-%d-%d:%d:%d:%d.csv", Curr_time.year, Curr_time.month, Curr_time.day, Curr_time.hour, Curr_time.minute, Curr_time.second, Curr_time.msecond); //Create filename (date, time) fp = fopen(fname,"w"); //Open file struct sockaddr_in outsock; int s_out_sensordata, slen = sizeof(struct sockaddr_in); initClientSocket(IMU_PORT, &s_out_sensordata, OPC_IP, &outsock); //initClientSocket(65100, &s_out_sensordata, "10.0.0.10", &outsock); //fakeclient sensor_data data; initBuffer(); while(running) { data = receiveSensorData(); writeToBuffer(&data); if (processData(&data)) sendSensorData(&data, s_out_sensordata, outsock, slen); } //At end by Ctrl+c printf("Fin\n"); fclose(fp); //Close file return 0; }
Ostream& OPstream::write(const floatScalar s) { write(char(token::FLOAT_SCALAR)); writeToBuffer(s); return *this; }
Ostream& OPstream::write(const doubleScalar s) { write(char(token::DOUBLE_SCALAR)); writeToBuffer(s); return *this; }
void render() { // Clears the buffer with this colour attribute clearBuffer(0x00); // Set up sample colours, and output shadings COORD c; // displays the framerate std::ostringstream ss; ss << std::fixed << std::setprecision(3); ss << 1.0 / deltaTime << "fps"; c.X = ConsoleSize.X-9; c.Y = 0; writeToBuffer(c, ss.str()); // displays the elapsed time ss.str(""); ss << elapsedTime << "secs"; c.X = 0; c.Y = 0; writeToBuffer(c, ss.str(), 0x59); if ( menu == 1 ) { rendMainMenu(); } else if ( option == 1 ) { rendOptions(); } else if ( game == 1 ) { c.X = 40; c.Y = 15; writeToBuffer(c, "In game state"); flushBufferToConsole(); } else if ( Ship == 1 ) { rendChoose(); } flushBufferToConsole(); }
Ostream& OPstream::write(const label l) { write(char(token::LABEL)); writeToBuffer(l); return *this; }
int Caen785Module::acquire(Event *ev) { int nofRead = 0; nofRead = acquireSingleEventMBLT(); //ret = acquireSingleEvent(); //ret = acquireSingleEventFIFO(); if(nofRead > 0) writeToBuffer(ev, nofRead); return nofRead; }
Foam::Ostream& Foam::OPstream::write(const char c) { if (!isspace(c)) { writeToBuffer(c); } return *this; }
/** Bitmap */ void Effects::showBitmap(byte bitmapIdx, byte duration, eColors color) { word matrix [16]; renderer.clearScreenBuffer(matrix); for (byte i = 0; i < 10; i++) { for (byte j = 0; j < 11; j++) { matrix[i] |= ((pgm_read_word_near(&(bitmaps[bitmapIdx - BITMAP_MIN][j])) >> i) & 0x0001) << (15 - j); } } writeToBuffer(matrix, 15 * duration, color); }
void cluster_t::update_u_gpu(){ #ifdef USE_GPU writeToBuffer(buffer_dist_func,1,&dist_func,"buffer_dist_func"); writeToBuffer(buffer_rho,1,&rho,"buffer_rho"); int x_dim = BLOCK_WIDTH * variable_blocks; runKernel("update_U",kernel_update_U,x_dim,n,1,BLOCK_WIDTH,1,1); bool debug_gpu = false; if(debug_gpu){ float testArr[n*p]; readFromBuffer(buffer_U,n*p,testArr,"buffer_U"); for(int i=0;i<n;++i){ for(int j=0;j<p;++j){ if(i==(n-10) && j>(p-10)){ cerr<<"update U GPU: U: "<<i<<","<<j<<": "<<testArr[i*p+j]<<endl; } } } } #endif }
Foam::Ostream& Foam::OPstream::write(const char* data, std::streamsize count) { if (format() != BINARY) { FatalErrorIn("Ostream::write(const char*, std::streamsize)") << "stream format not binary" << Foam::abort(FatalError); } writeToBuffer(data, count, 8); return *this; }
void SubRequestBin::specificHandler() { buf = new QBuffer(); buf->open(QIODevice::ReadWrite); connect(netReply, SIGNAL(readyRead()), this, SLOT(writeToBuffer())); connect(netReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(checkProgress(qint64,qint64))); connect(netReply, SIGNAL(finished()), this, SLOT(finishedDownloading())); }
bool SgsClient::talk(const std::string &msg) { if (msg.empty() || msg.size() > 500) return false; uLong len = compressBound(msg.size()); char *dt = new char[len + 6]; compress((Bytef*)dt + 6, &len, (Bytef*)msg.c_str(), msg.length()); if (len > SGS_MAX_TALK_LEN) { delete dt; return false; } writeToBuffer(dt + 5, (uint8_t)len); uint8_t clen = msg.size() / 2; if ((msg.size() & 1) == 1)//不能被2整除 clen++; writeToBuffer(dt + 4, clen); uint16_t slen = (uint16_t)len + 2; writeToBuffer(dt + 2, slen); slen = Command_Talk; writeToBuffer(dt, slen); rawSend(dt, len + 6); return true; }
static char* writeKeyToBuffer(const char *key, size_t keylen, char *buftop, char *bufend) { if(buftop < bufend) { writeToBuffer('"', buftop, bufend); } buftop = writeFixedTextToBuffer(key, keylen, buftop, bufend); if(buftop + 3 < bufend) { buftop[0] = '"'; buftop[1] = ':'; buftop[2] = ' '; buftop+=3; } return buftop; }
/** Feuerwerk-Effekt */ void Effects::showFireWork(byte posX, eColors color) { word matrix [16]; for (byte i = 9; i >= 3; i--) { renderer.clearScreenBuffer(matrix); ledDriver.setPixelInScreenBuffer(posX, i, matrix); writeToBuffer(matrix, 7, color); } for (byte i = 0; i <= 2; i++) { renderer.clearScreenBuffer(matrix); for (byte j = 0; j < 10; j++) { matrix[j] |= (pgm_read_word_near(&(effectMasksFireWork[i][j])) << (10 - posX)) & 0b1111111111100000; } writeToBuffer(matrix, 3 + round(10 * i / 3), color); } for (byte i = 0; i <= 10; i++) { renderer.clearScreenBuffer(matrix); for (byte j = 0; j < 10 - i; j++) { matrix[j + i] |= (pgm_read_word_near(&(effectMasksFireWork[3 + i % 3][j])) << (10 - posX)) & 0b1111111111100000; } writeToBuffer(matrix, 20, color); } }
/** Kerzen-Effekt */ void Effects::showCandle(eColors color) { word matrix [16]; for (byte k = 0; k < 5; k++) { for (int j = -4; j < 4; j++) { renderer.clearScreenBuffer(matrix); for (byte i = 5; i < 10; i++) { matrix[i] |= (pgm_read_word_near(&(effectMasksCandle[5][i])) << 5); } for (byte i = 0; i < 5; i++) { matrix[i] |= (pgm_read_word_near(&(effectMasksCandle[4 - abs(j % 4)][i])) << 5); } writeToBuffer(matrix, 10, color); } } }
/** Pulsierender Herz-Effekt */ void Effects::showHeart(byte duration, eColors color) { word matrix [16]; for (byte y = 0; y < 3; y++) { renderer.clearScreenBuffer(matrix); for (byte j = 0; j < 8; j++) { matrix[1 + j] |= (pgm_read_word_near(&(effectMasksHeart[0][j])) << 5); } writeToBuffer(matrix, 11 * duration, color); for (byte i = 0; i < 2; i++) { renderer.clearScreenBuffer(matrix); for (byte z = 0; z < 2; z++) { for (byte j = 0; j < 8; j++) { matrix[1 + j] |= (pgm_read_word_near(&(effectMasksHeart[z][j])) << 5); } writeToBuffer(matrix, 4 * duration, color); } } } renderer.clearScreenBuffer(matrix); for (byte j = 0; j < 8; j++) { matrix[1 + j] |= (pgm_read_word_near(&(effectMasksHeart[0][j])) << 5); } writeToBuffer(matrix, 14 * duration, color); }
void cluster_t::init_v_project_coeff_gpu(){ #ifdef USE_GPU float unweighted_lambda = mu * dist_func / rho; writeToBuffer(buffer_unweighted_lambda, 1, &unweighted_lambda, "buffer_unweighted_lambda"); runKernel("init_v_project_coeff",kernel_init_v_project_coeff,BLOCK_WIDTH*n,n,1,BLOCK_WIDTH,1,1); bool debug_gpu = false; if(debug_gpu){ float * testv = new float[triangle_dim]; readFromBuffer(buffer_V_project_coeff,triangle_dim,testv,"buffer_V_project_coeff"); for(int index1=0;index1<n-1;++index1){ for(int index2=index1+1;index2<n;++index2){ float & scaler = testv[offsets[index1]+(index2-index1)]; if (scaler !=0 && scaler !=1 ) cerr<<"GPU Init_V Index: "<<index1<<","<<index2<<": "<<scaler<<endl; } } } #endif }
void Effects::showTickerString(const char* str2disp, byte tickerSpeed, eColors color) { word matrix [16]; byte strLength = strlen(str2disp); unsigned int bufLen; char actChar; char lastChar; byte offsetV = 2; bool finish = false; unsigned int i = 0; while (!finish) { renderer.clearScreenBuffer(matrix); lastChar = 'W'; unsigned int shift = 0; // Schiebekorrektur aufgrund variierender Buchstabenbreite for (byte k = 0; k < strLength; k++) { actChar = str2disp[k]; if (actChar == ' ') { shift += 3; //bei einem Space eine Lücke von: } else { shift -= pgm_read_byte_near(&(stabenBig[lastChar - '!'][7])); for (byte j = 0; j < 7; j++) { matrix[offsetV + j] |= (pgm_read_byte_near(&(stabenBig[actChar - '!'][j])) << (1 - shift + i)) & 0b1111111111100000; } if (k < (strLength - 1)) { shift += 6; // Max. Buchstabenbreite + ein Pixel Lücke } lastChar = actChar; } } writeToBuffer(matrix, 3 * (10 - tickerSpeed), color); bufLen = shift + 15; if (i == bufLen) { finish = true; } else { i++; } } }
static char* writePolicyToBuffer(KonohaContext *kctx, logconf_t *logconf, char *buftop, char *bufend, KTraceInfo *trace) { if((logconf->policy & HasLocation)) { buftop = writeKeyToBuffer(TEXTSIZE("LogPoint"), buftop, bufend); writeToBuffer('"', buftop, bufend); if(KFlag_Is(int, logconf->policy, PeriodicPoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("PeriodicPoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, ResponseCheckPoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("ResponseCheckPoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SystemChangePoint)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SystemChangePoint,"), buftop, bufend); } if(KFlag_Is(int, logconf->policy, SecurityAudit)) { buftop = writeFixedTextToBuffer(TEXTSIZE("SecurityAudit,"), buftop, bufend); } buftop[-1] = '"'; buftop[0] = ','; buftop[1] = ' '; buftop+=2; }
/*!***************************************************************************** ******************************************************************************* \note run_ros_servo \date Feb 1999 \remarks This program executes the sequence of ros servo routines ******************************************************************************* Function Parameters: [in]=input,[out]=output none ******************************************************************************/ int run_ros_servo(void) { int j,i; double dt; int dticks; setOsc(d2a_cr,0.0); /********************************************************************* * adjust time */ ++ros_servo_calls; ros_servo_time += 1./(double)ros_servo_rate; servo_time = ros_servo_time; // check for unexpected time drift dticks = round((ros_servo_time - last_ros_servo_time)*(double)ros_servo_rate); if (dticks != 1 && ros_servo_calls > 2) // need transient ticks to sync servos ros_servo_errors += abs(dticks-1); /********************************************************************* * check for messages */ checkForMessages(); /********************************************************************* * receive sensory data */ if (!receive_ros_state()) { printf("Problem when receiving ros state\n"); return FALSE; } setOsc(d2a_cr,10.0); /********************************************************************* * compute useful kinematic variables */ compute_kinematics(); setOsc(d2a_cr,20.0); #ifdef __XENO__ // we want to be in secondary mode here //rt_task_set_mode(T_PRIMARY,0,NULL); #endif /********************************************************************** * do ROS communication */ if (default_publisher_enabled_) ros_communicator_.publish(); /********************************************************************** * do user specific ROS functions */ run_user_ros(); ros::spinOnce(); #ifdef __XENO__ // we want to be in real-time mode here #if (CONFIG_XENO_VERSION_MAJOR < 2) || (CONFIG_XENO_VERSION_MAJOR == 2 && CONFIG_XENO_VERSION_MINOR < 6) // we are on xenomai version < 2.6 rt_task_set_mode(0,T_PRIMARY,NULL); #else // we are on xenomai version < 2.6 rt_task_set_mode(0,T_CONFORMING,NULL); #endif #endif setOsc(d2a_cr,90.0); /************************************************************************* * collect data */ writeToBuffer(); sendOscilloscopeData(); setOsc(d2a_cr,100.0); /************************************************************************* * end of program sequence */ last_ros_servo_time = ros_servo_time; return TRUE; }
void MorphologicalDictionary::buildBufferFromTextFile(string _filePath) { bool debug = true; if (debug) { wcout << "Build buffer from text file..." << endl; } buffer = new unsigned char[100000000]; bufferSize = 0; wifstream fi(_filePath.c_str()); // set encoding to UTF-8 #ifdef MSVC fi.imbue(locale(fi.getloc(), new codecvt_utf8<wchar_t>)); #else //fin.imbue(std::locale("ru_RU.UTF-8")); fi.imbue(std::locale("en_US.UTF-8")); #endif wstring line; // Node getline(fi, line); int _number_of_nodes = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_nodes = tools->intToCharVector3(_number_of_nodes); writeToBuffer(_binary_number_of_nodes); for (int i = 0; i < _number_of_nodes; ++i) { getline(fi, line); vector<unsigned char> _binary_node_char; _binary_node_char.push_back(tools->wcharToChar(line.at(0))); writeToBuffer(_binary_node_char); getline(fi, line); int _node_parent_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_node_parent_id = tools->intToCharVector3(_node_parent_id); writeToBuffer(_binary_node_parent_id); } if (debug) { wcout << "#build : Node ok: " << _number_of_nodes << endl; } // NodeModel getline(fi, line); int _number_of_node_models = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_node_models = tools->intToCharVector3(_number_of_node_models); writeToBuffer(_binary_number_of_node_models); for (int i = 0; i < _number_of_node_models; ++i) { getline(fi, line); int _model_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_model_id = tools->intToCharVector2(_model_id); writeToBuffer(_binary_model_id); getline(fi, line); int _lemma_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_lemma_id = tools->intToCharVector3(_lemma_id); writeToBuffer(_binary_lemma_id); getline(fi, line); int _node_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_node_id = tools->intToCharVector3(_node_id); writeToBuffer(_binary_node_id); } if (debug) { wcout << "#build : NodeModel ok: " << _number_of_node_models << endl; } // TrieModel getline(fi, line); int _number_of_trie_models = atoi(tools->wstring2string(line).c_str()); wcout << "#build: _number_of_trie_models = " << _number_of_trie_models << endl; vector<unsigned char> _binary_number_of_trie_models = tools->intToCharVector2(_number_of_trie_models); writeToBuffer(_binary_number_of_trie_models); for (int i = 1; i <= _number_of_trie_models; ++i) { getline(fi, line); int _number_of_trie_model_elements = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_trie_model_elements = tools->intToCharVector1(_number_of_trie_model_elements); writeToBuffer(_binary_number_of_trie_model_elements); for (int j = 0; j < _number_of_trie_model_elements; ++j) { // suffix getline(fi, line); int _suffix_length = (int) line.length(); vector<unsigned char> _binary_suffix_length = tools->intToCharVector1(_suffix_length); writeToBuffer(_binary_suffix_length); vector<unsigned char> _binary_suffix = tools->wstringToCharVector(line); writeToBuffer(_binary_suffix); // begin with PO getline(fi, line); int _begin_with_po = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_begin_with_po = tools->intToCharVector1(_begin_with_po); writeToBuffer(_binary_begin_with_po); // featureListId getline(fi, line); int _feature_list_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_feature_list_id = tools->intToCharVector2(_feature_list_id); writeToBuffer(_binary_feature_list_id); } } if (debug) { wcout << "#build : TrieModels ok: " << _number_of_trie_models << endl; } // Feature lists getline(fi, line); int _number_of_feature_lists = atoi(tools->wstring2string(line).c_str()); if (debug) { wcout << "_number_of_feature_lists = " << _number_of_feature_lists << endl; } vector<unsigned char> _binary_number_of_feature_lists = tools->intToCharVector2(_number_of_feature_lists); writeToBuffer(_binary_number_of_feature_lists); for (int i = 0; i < _number_of_feature_lists; ++i) { getline(fi, line); int _number_of_features = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_features = tools->intToCharVector1(_number_of_features); writeToBuffer(_binary_number_of_features); for (int j = 0; j < _number_of_features; ++j) { getline(fi, line); int _feature_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_feature_id = tools->intToCharVector1(_feature_id); writeToBuffer(_binary_feature_id); } } if (debug) { wcout << "#build : Feature list ok: " << _number_of_feature_lists << endl; } // Features map getline(fi, line); int _number_of_features = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_features = tools->intToCharVector1(_number_of_features); writeToBuffer(_binary_number_of_features); for (int i = 1; i <= _number_of_features; ++i) { // short feature getline(fi, line); int _short_feature_length = (int) line.length(); //wcout << line << endl; vector<unsigned char> _short_binary_feature_length = tools->intToCharVector1(_short_feature_length); writeToBuffer(_short_binary_feature_length); vector<unsigned char> _short_binary_feature = tools->wstringToCharVector(line); writeToBuffer(_short_binary_feature); // long feature getline(fi, line); int _long_feature_length = (int) line.length(); vector<unsigned char> _long_binary_feature_length = tools->intToCharVector1(_long_feature_length); writeToBuffer(_long_binary_feature_length); vector<unsigned char> _long_binary_feature = tools->wstringToCharVector(line); writeToBuffer(_long_binary_feature); } if (debug) { wcout << "#build : Feature Map ok: " << _number_of_features << endl; } // SUFFIX: sumber of suffix = 641965 // Suffix nodes getline(fi, line); // number of nodes <= 188520 int _number_of_suffix_nodes = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_suffix_nodes = tools->intToCharVector3(_number_of_suffix_nodes); writeToBuffer(_binary_number_of_suffix_nodes); for (int i = 0; i < _number_of_suffix_nodes; ++i) { // node char getline(fi, line); vector<unsigned char> _binary_node_char; _binary_node_char.push_back(tools->wcharToChar(line.at(0))); writeToBuffer(_binary_node_char); getline(fi, line); // parent id int _suffix_node_parent_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_suffix_node_parent_id = tools->intToCharVector3(_suffix_node_parent_id); writeToBuffer(_binary_suffix_node_parent_id); // number of node models <= 556 getline(fi, line); int _number_of_node_models = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_node_models = tools->intToCharVector2(_number_of_node_models); writeToBuffer(_binary_number_of_node_models); // node models for (int j = 0; j < _number_of_node_models; ++j) { // suffix model id <= 632527 getline(fi, line); int _suffix_model_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_suffix_model_id = tools->intToCharVector3(_suffix_model_id); writeToBuffer(_binary_suffix_model_id); } } if (debug) { wcout << "#build : Suffix nodes ok: " << _number_of_suffix_nodes << endl; } // number of suffix models = 703729 getline(fi, line); int _number_of_suffix_models = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_number_of_suffix_models = tools->intToCharVector3(_number_of_suffix_models); writeToBuffer(_binary_number_of_suffix_models); // suffix models for (int _suffix_model_id = 0; _suffix_model_id < _number_of_suffix_models; ++_suffix_model_id) { // getline(fi, line); int _feature_list_id = atoi(tools->wstring2string(line).c_str()); vector<unsigned char> _binary_feature_list_id = tools->intToCharVector2(_feature_list_id); writeToBuffer(_binary_feature_list_id); // lemma suffix getline(fi, line); int _lemma_suffix_length = (int) line.length(); vector<unsigned char> _binary_lemma_suffix_length = tools->intToCharVector1(_lemma_suffix_length); writeToBuffer(_binary_lemma_suffix_length); vector<unsigned char> _binary_lemma_suffix = tools->wstringToCharVector(line); writeToBuffer(_binary_lemma_suffix); } if (debug) { wcout << "#build : Suffix models ok: " << _number_of_suffix_models << endl; } fi.close(); }