void main() { List<int> lst = { 1, 2, 3 }; printRaw(lst); // doesn't consume consume(lst); // consumes consume(std::move(lst)); printRaw(lst); { List<int> lst1{ 10, 20, 30, 40, 50 }; for (int x : lst1) std::cout << x << " "; std::cout << std::endl; OutListIter<int> out; auto it = std::transform(std::begin(lst1), std::end(lst1), out, [](int i) { return ++i; }); std::cout << it.getList() << std::endl; std::cout << lst1 << std::endl; auto lst2 = reverse(lst1); std::cout << lst2 << std::endl; } testLst(); testHigher(); }
void SevenSegmentExtended::printTime(uint8_t hour, uint8_t min, bool blink) { bool colonWasOn = getColonOn(); setColonOn(true); uint8_t buffer[4]; buffer[0] = encode((hour / 10)); buffer[1] = encode((hour % 10)); buffer[2] = encode((min / 10)); buffer[3] = encode((min % 10)); printRaw(buffer, 4, 0); // turn colon off and on again if (blink) { delay(TM1637_DEFAULT_BLINK_DELAY); setColonOn(false); printRaw(buffer[1],1); delay(TM1637_DEFAULT_BLINK_DELAY); setColonOn(true); printRaw(buffer[1],1); } setColonOn(colonWasOn); };
/* * Implementation of LogPrinter */ LogPrinter::LogPrinter(const char* logtag, android_LogPriority priority, const char* prefix, bool ignoreBlankLines) : mLogTag(logtag), mPriority(priority), mPrefix(prefix ?: ""), mIgnoreBlankLines(ignoreBlankLines) { } void LogPrinter::printLine(const char* string) { if (string == nullptr) { ALOGW("%s: NULL string passed in", __FUNCTION__); return; } if (mIgnoreBlankLines || (*string)) { // Simple case: Line is not blank, or we don't care about printing blank lines printRaw(string); } else { // Force logcat to print empty lines by adding prefixing with a space printRaw(" "); } } void LogPrinter::printRaw(const char* string) { __android_log_print(mPriority, mLogTag, "%s%s", mPrefix, string); }
void consume(List<int> lst) { printRaw(lst); while (!lst.isEmpty()) { std::cout << lst.front(); lst = lst.pop_front(); } printRaw(lst); }
// positive counter 0..99, negative counter 0..-9 void SevenSegmentExtended::printDualCounter(int8_t leftCounter, int8_t rightCounter, bool zeroPadding) { int8_t max = 99; int8_t min = -9; uint8_t zeroByte = encode('0'); leftCounter = (leftCounter > max)?max:leftCounter; leftCounter = (leftCounter < min)?min:leftCounter; rightCounter = (rightCounter > max)?max:rightCounter; rightCounter = (rightCounter < min)?min:rightCounter; Serial.println(leftCounter); Serial.println(rightCounter); bool colonWasOn = getColonOn(); // get current state setColonOn(true); // turn on the colon home(); // set cursor to zero if ( leftCounter < 10 && leftCounter >= 0) { if ( zeroPadding ) { printRaw(zeroByte,1); setCursor(0,1); } else { // print colon printRaw(TM1637_COLON_BIT,1); }; }; print(leftCounter); if ( rightCounter < 10 && rightCounter >= 0) { if ( zeroPadding ) { printRaw(zeroByte,2); } uint8_t pos = 2; printRaw(0,pos); setCursor(0,3); } else { setCursor(0,2); } print(rightCounter); // set to previous state setColonOn(colonWasOn); };
void CallStateParser::print() { qDebug()<<"isValid : "<<isValid; qDebug()<<"hasCall1 : "<<hasCall1; qDebug()<<"hasCall2 : "<<hasCall2; qDebug()<<"hasCall3 : "<<hasCall3; qDebug()<<"hasCall4 : "<<hasCall4; qDebug()<<"hasBroadcast : "<<hasBroadcast; qDebug()<<"hasBroadcast_lc : "<<hasBroadcast_lc; printRaw(); }
void RailwayStateParser::print() { if(stationType == 1) qDebug()<<"english start station"; if(stationType == 2) qDebug()<<"english end station"; if(stationType == 3) qDebug()<<"Thai start station"; if(stationType == 4) qDebug()<<"Thai statrt station"; qDebug()<<"stationName : "<<stationName; printRaw(); }
//---------------------------------------------------------------------------------------------------- void Context::print (const char* fmt, ...) { va_list args; va_start (args, fmt); char* str = 0; // TODO: Windows alternative implementation needed ! #if !_WIN32 if (vasprintf (&str, fmt, args) >= 0 && str != 0) { printRaw (str); free (str); } #endif }
int load(Arguments& info) { ESM::ESMReader& esm = info.reader; ToUTF8::Utf8Encoder encoder (ToUTF8::calculateEncoding(info.encoding)); esm.setEncoder(&encoder); std::string filename = info.filename; std::cout << "Loading file: " << filename << std::endl; std::list<int> skipped; try { if(info.raw_given && info.mode == "dump") { std::cout << "RAW file listing:\n"; esm.openRaw(filename); printRaw(esm); return 0; } bool quiet = (info.quiet_given || info.mode == "clone"); bool loadCells = (info.loadcells_given || info.mode == "clone"); bool save = (info.mode == "clone"); esm.open(filename); info.data.author = esm.getAuthor(); info.data.description = esm.getDesc(); info.data.masters = esm.getGameFiles(); if (!quiet) { std::cout << "Author: " << esm.getAuthor() << std::endl << "Description: " << esm.getDesc() << std::endl << "File format version: " << esm.getFVer() << std::endl; std::vector<ESM::Header::MasterData> m = esm.getGameFiles(); if (!m.empty()) { std::cout << "Masters:" << std::endl; for(unsigned int i=0;i<m.size();i++) std::cout << " " << m[i].name << ", " << m[i].size << " bytes" << std::endl; } } // Loop through all records while(esm.hasMoreRecs()) { ESM::NAME n = esm.getRecName(); uint32_t flags; esm.getRecHeader(flags); // Is the user interested in this record type? bool interested = true; if (info.types.size() > 0) { std::vector<std::string>::iterator match; match = std::find(info.types.begin(), info.types.end(), n.toString()); if (match == info.types.end()) interested = false; } std::string id = esm.getHNOString("NAME"); if(!quiet && interested) std::cout << "\nRecord: " << n.toString() << " '" << id << "'\n"; EsmTool::RecordBase *record = EsmTool::RecordBase::create(n); if (record == 0) { if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end()) { std::cout << "Skipping " << n.toString() << " records." << std::endl; skipped.push_back(n.val); } esm.skipRecord(); if (quiet) break; std::cout << " Skipping\n"; } else { if (record->getType().val == ESM::REC_GMST) { // preset id for GameSetting record record->cast<ESM::GameSetting>()->get().mId = id; } record->setId(id); record->setFlags((int) flags); record->setPrintPlain(info.plain_given); record->load(esm); if (!quiet && interested) record->print(); if (record->getType().val == ESM::REC_CELL && loadCells) { loadCell(record->cast<ESM::Cell>()->get(), esm, info); } if (save) { info.data.mRecords.push_back(record); } else { delete record; } ++info.data.mRecordStats[n.val]; } } } catch(std::exception &e) { std::cout << "\nERROR:\n\n " << e.what() << std::endl; typedef std::deque<EsmTool::RecordBase *> RecStore; RecStore &store = info.data.mRecords; for (RecStore::iterator it = store.begin(); it != store.end(); ++it) { delete *it; } store.clear(); return 1; } return 0; }