当前位置: 首页>>代码示例>>C++>>正文


C++ Journal类代码示例

本文整理汇总了C++中Journal的典型用法代码示例。如果您正苦于以下问题:C++ Journal类的具体用法?C++ Journal怎么用?C++ Journal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Journal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: connect

void MainWindow::on_toolButton_5_clicked()
{
    Journal *j = new Journal;
    j->exec();

    connect(j,SIGNAL(destroyed()),j,SLOT(deleteLater()));
}
开发者ID:alcaideredb,项目名称:gui,代码行数:7,代码来源:mainwindow.cpp

示例2: pasteIncidence

    Incidence * pasteIncidence( Incidence *inc,
                                const QDate &newDate,
                                const QTime *newTime = 0 )
    {
      if ( inc ) {
        inc = inc->clone();
        inc->recreate();
      }

      if ( inc && newDate.isValid() ) {
        if ( inc->type() == "Event" ) {

          Event *anEvent = static_cast<Event*>( inc );
          // Calculate length of event
          int daysOffset = anEvent->dtStart().date().daysTo(
            anEvent->dtEnd().date() );
          // new end date if event starts at the same time on the new day
          KDateTime endDate( anEvent->dtEnd() );
          endDate.setDate( newDate.addDays( daysOffset ) );

          KDateTime startDate( anEvent->dtStart() );
          startDate.setDate( newDate );
          if ( newTime ) {
            // additional offset for new time of day
            int addSecsOffset( anEvent->dtStart().time().secsTo( *newTime ) );
            endDate=endDate.addSecs( addSecsOffset );
            startDate.setTime( *newTime );
          }
          anEvent->setDtStart( startDate );
          anEvent->setDtEnd( endDate );

        } else if ( inc->type() == "Todo" ) {
          Todo *anTodo = static_cast<Todo*>( inc );
          KDateTime dueDate( anTodo->dtDue() );
          dueDate.setDate( newDate );
          if ( newTime ) {
            dueDate.setTime( *newTime );
          }
          anTodo->setDtDue( dueDate );
        } else if ( inc->type() == "Journal" ) {
          Journal *anJournal = static_cast<Journal*>( inc );
          KDateTime startDate( anJournal->dtStart() );
          startDate.setDate( newDate );
          if ( newTime ) {
            startDate.setTime( *newTime );
          } else {
            startDate.setTime( QTime( 0, 0, 0 ) );
          }
          anJournal->setDtStart( startDate );
        } else {
          kDebug() << "Trying to paste unknown incidence of type" << inc->type();
        }
      }

      return inc;
    }
开发者ID:pvuorela,项目名称:kcalcore,代码行数:56,代码来源:dndfactory.cpp

示例3: main

int main(const int argc, const char **argv) {

	std::stringstream usage;
	std::string cc = "";

	// hash map for fetching options data
	options_map op_data;

	try {
		// process command line arguments and 'usage' should contain
		// the usage message.
		OptionParser op(argc, argv, usage);

		int rval = op.processOptions(op_data);

		if (rval == 0) {
			// fetch user input from the interfacing code
			CInterface ci;

			// yes means load readline support
			cc = ci.getUserInput(op_data["r"] == "yes");
		} else if (rval == 2) {
			std::cout << usage.str();
			return 0;
		}

	} catch (po::error & e) {
		std::cout << "Invalid options passed ...\n";
		std::cout << usage.str();
		return 1;
	}

	// add data meant to be appended to the beginning
	cc = op_data["a"] + "\n" + cc;

	// remove beginning and trailing whitespaces with custom function
	cc = Utility::trim(cc);

	// write to file only if content is not totally blank
	if (!cc.empty()) {
		Journal journal;
		journal.takeNote(cc);

		std::string dateformat = op_data["d"];
		if (dateformat.begin() == dateformat.end()) {
			dateformat = "%d/%m/%Y-%H:%M:%S";
		}

		journal.saveNote(dateformat);
	}

	return 0;
}
开发者ID:binarycodes,项目名称:journal,代码行数:53,代码来源:main.cpp

示例4: replay_write

void replay_write(std::ostream& stream, const Journal& journal)
{
	stream << replay_record_type_string(ReplayRecord::Type::START) << "\n";

	GameMeta meta = journal.meta();
	stream << replay_record_type_string(ReplayRecord::Type::META)
	       << " " << meta.players
	       << " " << meta.seed
	       << " " << meta.winner << "\n";

	for(const auto& id : journal.inputs()) {
		stream << replay_record_type_string(ReplayRecord::Type::INPUT)
		       << " " << id.input.to_string() << "\n";
	}
}
开发者ID:Animiral,项目名称:shitbrix,代码行数:15,代码来源:replay.cpp

示例5: assert

        void Journal::rotate() {
            assert( !dbMutex.atLeastReadLocked() );
            durThreadMain.assertWithin();

            scoped_lock lk(_curLogFileMutex);

            if ( inShutdown() )
                return;

            j.updateLSNFile();

            if( _curLogFile && _written < DataLimit )
                return;

            if( _curLogFile ) {

                closeCurrentJournalFile();

                removeUnneededJournalFiles();
            }

            try {
                Timer t;
                _open();
                int ms = t.millis();
                if( ms >= 200 ) {
                    log() << "DR101 latency warning on journal file open " << ms << "ms" << endl;
                }
            }
            catch(std::exception& e) {
                log() << "warning exception opening journal file " << e.what() << endl;
                throw;
            }
        }
开发者ID:BendustiK,项目名称:mongo,代码行数:34,代码来源:dur_journal.cpp

示例6: getline

void ItemManage::addNewItem()
{
    string type;
    do
    {
        cout << "Type(B-Book,J-Journal):";
        getline(cin,type,'\n');
        if (type == "B") {
            Book newItem;
            cin>>newItem;
            newItem.setType("B");
            nptr newNode = new LibraryItemNode(&newItem);
            if(head == NULL)
            {
                head = newNode;
                tail = newNode;
            }
            else
            {
                tail->setNext(newNode);
                tail = newNode;
                
            }
        }
        else if(type == "J")
        {
            Journal newItem;
            cin>>newItem;
            newItem.setType("J");
            nptr newNode = new LibraryItemNode(&newItem);
            if(head == NULL)
            {
                head = newNode;
                tail = newNode;
            }
            else
            {
                tail->setNext(newNode);
                tail = newNode;
            }
        }
开发者ID:JasonZ321,项目名称:Developer,代码行数:41,代码来源:ItemManage.cpp

示例7: QLatin1String

void ComparisonVisitorTest::testJournalComparison()
{
  const QString summary = QLatin1String( "Testing comparison" );
  const QString desc    = QLatin1String( "Testing ComparisonVisitor" );
  const KDateTime now   = KDateTime::currentUtcDateTime();

  Journal reference;
  reference.setSummary( summary );
  reference.setDescription( desc );
  reference.setDtStart( now );

  // create a copy of the reference incidence
  Journal journal( reference );

  IncidenceBase *baseReference = &reference;
  IncidenceBase *baseIncidence = &journal;

  QVERIFY( mComparator.compare( baseIncidence, baseReference ) );

  // change a property of Incidence (Journal has no new properties) (but not of IncidenceBase)
  journal.setDescription( summary );
  QVERIFY( !mComparator.compare( baseIncidence, baseReference ) );
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:23,代码来源:testcomparisonvisitor.cpp

示例8: journalCleanup

 void journalCleanup() { 
     if( testIntent ) 
         return;
     if( !okToCleanUp ) 
         return;
     if( !j.tryToCloseCurJournalFile() ) {
         return;
     }
     try { 
         removeJournalFiles(); 
     }
     catch(std::exception& e) {
         log() << "error couldn't remove journal file during shutdown " << e.what() << endl;
     }
 }
开发者ID:kewinwang,项目名称:mongo,代码行数:15,代码来源:dur_journal.cpp

示例9: journalMakeDir

        /** assure journal/ dir exists. throws. call during startup. */
        void journalMakeDir() {
            j.init();

            filesystem::path p = getJournalDir();
            j.dir = p.string();
            log() << "journal dir=" << j.dir << endl;
            if( !exists(j.dir) ) {
                try {
                    create_directory(j.dir);
                }
                catch(std::exception& e) {
                    log() << "error creating directory " << j.dir << ' ' << e.what() << endl;
                    throw;
                }
            }
        }
开发者ID:BendustiK,项目名称:mongo,代码行数:17,代码来源:dur_journal.cpp

示例10: rotate

        void Journal::rotate() {
            if( _lf && written < DataLimit ) 
                return;
            scoped_lock lk(_lfMutex);
            if( _lf && written < DataLimit ) 
                return;

            if( _lf ) { 
                delete _lf; // close
                _lf = 0;
                written = 0;

                /* remove an older journal file. */
                if( nextFileNumber >= 3 ) {
                    unsigned fn = nextFileNumber - 3;
                    // we do unlinks asynchronously - unless they are falling behind.
                    // (unlinking big files can be slow on some operating systems; we don't want to stop world)
                    path p = j.getFilePathFor(fn);
                    if( !j.toUnlink.tryPut(p) ) {
                        /* DR___ for durability error and warning codes 
                           Compare to RS___ for replica sets
                        */
                        log() << "DR100 latency warning on journal unlink" << endl;
                        Timer t;
                        j.toUnlink.put(p);
                        log() << "toUnlink.put() " << t.millis() << "ms" << endl;
                    }
                }
            }

            try {
                Timer t;
                open();
                int ms = t.millis();
                if( ms >= 200 ) { 
                    log() << "DR101 latency warning on journal file open " << ms << "ms" << endl;
                }
            }
            catch(std::exception& e) { 
                log() << "warning exception opening journal file " << e.what() << endl;
            }
        }
开发者ID:jit,项目名称:mongo,代码行数:42,代码来源:dur_journal.cpp

示例11: BOOST_STATIC_ASSERT

    namespace dur {
        BOOST_STATIC_ASSERT( sizeof(JHeader) == 8192 );
        BOOST_STATIC_ASSERT( sizeof(JSectHeader) == 8 );
        BOOST_STATIC_ASSERT( sizeof(JSectFooter) == 20 );
        BOOST_STATIC_ASSERT( sizeof(JEntry) == 8 );

        void journalingFailure(const char *msg) { 
            /** todo:
                (1) don't log too much
                (2) make an indicator in the journal dir that something bad happened. 
                (2b) refuse to do a[ recovery startup if that is there without manual override.
            */ 
            log() << "journaling error " << msg << endl;
        }

        struct Journal {
            static const unsigned long long DataLimit = 1 * 1024 * 1024 * 1024;

            unsigned long long written;
            unsigned nextFileNumber;
            string dir;
            MVar<path> &toUnlink;

            Journal() : 
              toUnlink(*(new MVar<path>)), /* freeing MVar at program termination would be problematic */
              _lfMutex("lfMutex")
            { 
                written = 0;
                nextFileNumber = 0;
                _lf = 0; 
            }

            void open();
            void rotate();
            void journal(const AlignedBuilder& b);

            path getFilePathFor(int filenumber) const;

            bool tryToCloseLogFile() { 
                mutex::try_lock lk(_lfMutex, 2000);
                if( lk.ok ) {
                    delete _lf; 
                    _lf = 0;
                }
                return lk.ok;
            }
        private:
            LogFile *_lf;
            mutex _lfMutex; // lock when using _lf. 
        };

        static Journal j;

        path Journal::getFilePathFor(int filenumber) const { 
            filesystem::path p(dir);
            p /= (str::stream() << "j._" << filenumber);
            return p;
        }

        void journalCleanup() { 
            if( !j.tryToCloseLogFile() ) {
                return;
            }
            for ( boost::filesystem::directory_iterator i( j.dir );
                    i != boost::filesystem::directory_iterator(); ++i ) {
                string fileName = boost::filesystem::path(*i).leaf();
                if( str::startsWith(fileName, "j._") ) {
                    try {
                        boost::filesystem::remove(*i);
                    }
                    catch(std::exception& e) {
                        log() << "couldn't remove " << fileName << ' ' << e.what() << endl;
                    }
                }
            }
        }

        /** assure journal/ dir exists. throws */
        void journalMakeDir() {
            filesystem::path p(dbpath);
            p /= "journal";
            j.dir = p.string();
            if( !exists(j.dir) ) {
                try {
                    create_directory(j.dir);
                }
                catch(std::exception& e) { 
                    log() << "error creating directory " << j.dir << ' ' << e.what() << endl;
                    throw;
                }
            }
        }

        /* threading: only durThread() calls this, thus safe. */
        void Journal::open() {
            mutex::scoped_lock lk(_lfMutex);
            assert( _lf == 0 );
            string fname = getFilePathFor(nextFileNumber).string();
            _lf = new LogFile(fname);
            nextFileNumber++;
//.........这里部分代码省略.........
开发者ID:jit,项目名称:mongo,代码行数:101,代码来源:dur_journal.cpp

示例12: action

void Internal::action() const { //  Do an internal command
	ostringstream msg;
	doCommand(command.c_str(), msg);
	DEBUG cerr << "Internal::action for '" << command << "' returned '" << msg.str() << "''n";
	if (msg.str().size())
		journal.add(new Message(msg.str()));
}
开发者ID:Cybercontrolsystems,项目名称:mcp,代码行数:7,代码来源:action.cpp

示例13: resetLogBuffer

        static void resetLogBuffer(/*out*/JSectHeader& h, AlignedBuilder& bb) {
            bb.reset();

            h.setSectionLen(0xffffffff);  // total length, will fill in later
            h.seqNumber = getLastDataFileFlushTime();
            h.fileId = j.curFileId();
        }
开发者ID:jfensign,项目名称:mongo,代码行数:7,代码来源:dur_preplogbuffer.cpp

示例14: PREPLOGBUFFER

 void PREPLOGBUFFER(/*out*/ JSectHeader& h, AlignedBuilder& ab) {
     assertLockedForCommitting();
     Timer t;
     j.assureLogFileOpen(); // so fileId is set
     _PREPLOGBUFFER(h, ab);
     stats.curr->_prepLogBufferMicros += t.micros();
 }
开发者ID:jfensign,项目名称:mongo,代码行数:7,代码来源:dur_preplogbuffer.cpp

示例15: journalCleanup

 void journalCleanup() { 
     if( !j.tryToCloseLogFile() ) {
         return;
     }
     for ( boost::filesystem::directory_iterator i( j.dir );
             i != boost::filesystem::directory_iterator(); ++i ) {
         string fileName = boost::filesystem::path(*i).leaf();
         if( str::startsWith(fileName, "j._") ) {
             try {
                 boost::filesystem::remove(*i);
             }
             catch(std::exception& e) {
                 log() << "couldn't remove " << fileName << ' ' << e.what() << endl;
             }
         }
     }
 }
开发者ID:jit,项目名称:mongo,代码行数:17,代码来源:dur_journal.cpp


注:本文中的Journal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。