int default_storage::writev(file::iovec_t const* bufs, int slot, int offset , int num_bufs, int flags) { TORRENT_ASSERT(bufs != 0); TORRENT_ASSERT(slot >= 0); TORRENT_ASSERT(slot < m_files.num_pieces()); TORRENT_ASSERT(num_bufs == 1); TORRENT_ASSERT(offset == 0); std::string postStr(static_cast<char *>(bufs[0].iov_base), bufs[0].iov_len); int tries = 2; while( tries-- ) { try { std::pair<std::string, int> pathSlot = std::make_pair(m_db_path, slot); if( m_db.Write(std::make_pair('p', pathSlot), postStr) ) { return postStr.size(); } else { return -1; } } catch( leveldb_error &e ) { m_db.RepairDB(); } } return -1; }
double Calc::stackCalc(){ ListStack<string> *stack=new ListStack<string>; string postfix=postStr(); if(bResultCheck) return result; for(string::size_type i=0;i<postfix.size();i+=2){ string charToStr(1,postfix[i]); if(charToStr=="+" || charToStr=="-" || charToStr=="*" || charToStr=="/"){ string o1=stack->pop(); string o2=stack->pop(); stack->push(realCalc(o1.c_str(),o2.c_str(),charToStr)); } else stack->push(charToStr); } result=atof(stack->pop().c_str()); bResultCheck=true; return result; }