コード例 #1
0
void FileHandler::loadPatient(string fileName, PatientList& p_list) // 파일 읽기용
{
	IOHandler ioh;
	ifstream fin;
	fin.open(fileName, ios_base::in);

	int id; // 환자번호
	string name; // 성명
	string sex; // 성별
	int birth; // 생일
	string phone_number; // 휴대폰번호
	string ad_date; // 입원일
	string disease; // 병명
	string room; // 병실
	string doctor; // 주치의
	string nurse; // 담당간호사
	string leave_date; // 퇴원일
	
	while (!fin.eof()) // 파일의 끝에 도달하지 않았다면 계속 반복
	{
		fin >> id >> name >> sex >> birth >> phone_number >> ad_date >> disease >> leave_date; // 파일의 값을 읽음
		Patient p(id, name, sex, birth, phone_number, ad_date, disease, room, doctor, nurse, leave_date); // 생성자

		int index = p_list.findLeaveDate(leave_date);
		if (index != NOT_FOUND) // 중복 예외처리
		{
			ioh.putString("Already exists!"); // 이미 존재한다

			return;
		}
		p_list.insertPatient(p);
	}

	fin.close();
}
コード例 #2
0
ファイル: tcpprotocol.cpp プロジェクト: 2php/crtmpserver-1
TCPProtocol::~TCPProtocol() {
	if (_pCarrier != NULL) {
		IOHandler *pCarrier = _pCarrier;
		_pCarrier = NULL;
		pCarrier->SetProtocol(NULL);
		delete pCarrier;
	}
}
コード例 #3
0
ファイル: protocolmanager.cpp プロジェクト: OpenQCam/qcam
bool protocolManagerNetworkedProtocolsFilter(BaseProtocol *pProtocol) {
  IOHandler *pIOHandler = pProtocol->GetIOHandler();
  if ((pIOHandler == NULL)
      || ((pIOHandler->GetType() != IOHT_TCP_CARRIER)
      && (pIOHandler->GetType() != IOHT_UDP_CARRIER)))
    return false;
  return true;
}
コード例 #4
0
ファイル: REPL.cpp プロジェクト: kraj/lldb
void REPL::IOHandlerActivated(IOHandler &io_handler) {
  lldb::ProcessSP process_sp = m_target.GetProcessSP();
  if (process_sp && process_sp->IsAlive())
    return;
  lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFile());
  error_sp->Printf("REPL requires a running target process.\n");
  io_handler.SetIsDone(true);
}
コード例 #5
0
void ProtocolManager::GetNetworkedProtocols(map<uint32_t, BaseProtocol *> &result) {
    result.clear();
    FOR_MAP(_activeProtocols, uint32_t, BaseProtocol *, i) {
        BaseProtocol *pProtocol = MAP_VAL(i)->GetNearEndpoint();
        if (MAP_HAS1(result, pProtocol->GetId()))
            continue;
        IOHandler *pIOHandler = pProtocol->GetIOHandler();
        if ((pIOHandler == NULL)
                || ((pIOHandler->GetType() != IOHT_TCP_CARRIER)
                    && (pIOHandler->GetType() != IOHT_UDP_CARRIER)))
            continue;
        result[pProtocol->GetId()] = pProtocol;
    }
コード例 #6
0
ファイル: REPL.cpp プロジェクト: Aj0Ay/lldb
int
REPL::IOHandlerFixIndentation (IOHandler &io_handler,
                               const StringList &lines,
                               int cursor_position)
{
    if (!m_enable_auto_indent) return 0;
    
    if (!lines.GetSize())
    {
        return 0;
    }
    
    int tab_size = io_handler.GetDebugger().GetTabSize();

    lldb::offset_t desired_indent = GetDesiredIndentation(lines,
                                                          cursor_position,
                                                          tab_size);
    
    int actual_indent = REPL::CalculateActualIndentation(lines);
    
    if (desired_indent == LLDB_INVALID_OFFSET)
        return 0;
    
    return (int)desired_indent - actual_indent;
}
コード例 #7
0
void getCount(IOHandler& io)
{
    cout<<endl;
    cout<<"\nPART 2 TESTING FUNCTION: getCount()"<<endl;

    cout<<"Total comparisons and assignments: "<<io.getCount()<<endl;

}
コード例 #8
0
    virtual void
    IOHandlerInputComplete (IOHandler &io_handler, std::string &line)
    {
        io_handler.SetIsDone(true);

        // The WatchpointOptions object is owned by the watchpoint or watchpoint location
        WatchpointOptions *wp_options = (WatchpointOptions *) io_handler.GetUserData();
        if (wp_options)
        {
            std::unique_ptr<WatchpointOptions::CommandData> data_ap(new WatchpointOptions::CommandData());
            if (data_ap.get())
            {
                data_ap->user_source.SplitIntoLines(line);
                BatonSP baton_sp (new WatchpointOptions::CommandBaton (data_ap.release()));
                wp_options->SetCallback (WatchpointOptionsCallbackFunction, baton_sp);
            }
        }
    }
コード例 #9
0
 void
 IOHandlerActivated (IOHandler &io_handler) override
 {
     StreamFileSP output_sp(io_handler.GetOutputStreamFile());
     if (output_sp)
     {
         output_sp->PutCString(g_reader_instructions);
         output_sp->Flush();
     }
 }
コード例 #10
0
void deleteMin(IOHandler& io)
{
    cout<<endl<<endl;
    cout<<"\nPART 3 TESTING FUNCTION: deleteMin()"<<endl;

    for(int i = 1; i<11; i++)
    {
        cout<<i<<"] \""<<io.getMinString()<<"\""<<endl;
        cout<<"    LINES: ";
        list<int> outputList = io.deleteMin();
        for (std::list<int>::iterator it = outputList.begin(); it != outputList.end(); it++)
        {
            if (*it!= outputList.back())
                cout << *it << ",";
            else cout<<*it<<" ";
        }

        cout<< endl;
        cout<< endl;

    }
}
コード例 #11
0
void fastInsert(IOHandler& io)
{
    cout<<"\nPART 6 TESTING FUNCTION: fastInsert(string word)"<<endl;
    cout<<"Original Vector Indices:"<<endl;
    io.outputScannedIndices();
    cout<<endl;
    string ans;
    string word;
    do
    {
        cout<<"Please enter a string for fast insert:"<<endl;
        cin>>word;
        io.fastInsert(word);
//cout<<"New indices after fast insert: \n";
      //  io.outputScannedIndices();


        cout<<"To search again enter 'y' else hit any key: ";
        cin>>ans;
        cout<<endl<<endl;

    }while(ans=="y");
}
コード例 #12
0
void removeString(IOHandler& io)
{
      cout<<"\nPART 5 TESTING FUNCTION: removeString(string word)//non-min-delete: "<<endl;

    string input;
    for(int i = 0; i<5; i++)
    {
        cout<<i+1<<"] Please enter a key for removal: ";
        cin>>input;
        if (io.removeKey(input) == 0)
        {
            cout<<"KEY : \""<<input<<"\" unfound"<<endl;
        }
        else
            cout<<"KEY : \""<<input<<"\": checked & successfully deleted"<<endl;
    }
}
コード例 #13
0
 void
 IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override
 {
     io_handler.SetIsDone(true);
     
     std::vector<BreakpointOptions *> *bp_options_vec = (std::vector<BreakpointOptions *> *)io_handler.GetUserData();
     for (BreakpointOptions *bp_options : *bp_options_vec)
     {
         if (!bp_options)
             continue;
                 
         std::unique_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData());
         if (data_ap.get())
         {
             data_ap->user_source.SplitIntoLines (line.c_str(), line.size());
             BatonSP baton_sp (new BreakpointOptions::CommandBaton (data_ap.release()));
             bp_options->SetCallback (BreakpointOptionsCallbackFunction, baton_sp);
         }
     }
 }
コード例 #14
0
void find(IOHandler& io)
{

    cout<<endl<<endl;
    cout<<"\nPART 4 TESTING FUNCTION: find()"<<endl;

    string ans;

    do
    {
        string searchKey;
        cout<<"Please enter a key to find: ";
        cin>>searchKey;
        cout<<"KEY:     \""<< searchKey <<"\""<<endl;
        list<int> outputList = io.find(searchKey);

        if (outputList.front() == -1)
            cout<<"STATUS:"<< "    NULL"<<endl;
        else
        {
            cout<<"STATUS:   "<<"found. "<<endl;
            cout<<"LINES: ";

            for (std::list<int>::iterator it = outputList.begin(); it != outputList.end(); it++)
            {
                if (*it!= outputList.back())
                    cout << *it << ",";
                else cout<<*it<<" ";
            }
            cout<<endl;
        }
        cout<<"To search again enter 'y' else hit any key: ";
        cin>>ans;
        cout<<endl;

    }
    while (ans == "y");
}
コード例 #15
0
ファイル: REPL.cpp プロジェクト: kraj/lldb
void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
  lldb::StreamFileSP output_sp(io_handler.GetOutputStreamFile());
  lldb::StreamFileSP error_sp(io_handler.GetErrorStreamFile());
  bool extra_line = false;
  bool did_quit = false;

  if (code.empty()) {
    m_code.AppendString("");
    static_cast<IOHandlerEditline &>(io_handler)
        .SetBaseLineNumber(m_code.GetSize() + 1);
  } else {
    Debugger &debugger = m_target.GetDebugger();
    CommandInterpreter &ci = debugger.GetCommandInterpreter();
    extra_line = ci.GetSpaceReplPrompts();

    ExecutionContext exe_ctx(m_target.GetProcessSP()
                                 ->GetThreadList()
                                 .GetSelectedThread()
                                 ->GetSelectedFrame()
                                 .get());

    lldb::ProcessSP process_sp(exe_ctx.GetProcessSP());

    if (code[0] == ':') {
      // Meta command
      // Strip the ':'
      code.erase(0, 1);
      if (Args::StripSpaces(code)) {
        // "lldb" was followed by arguments, so just execute the command dump
        // the results

        // Turn off prompt on quit in case the user types ":quit"
        const bool saved_prompt_on_quit = ci.GetPromptOnQuit();
        if (saved_prompt_on_quit)
          ci.SetPromptOnQuit(false);

        // Execute the command
        CommandReturnObject result;
        result.SetImmediateOutputStream(output_sp);
        result.SetImmediateErrorStream(error_sp);
        ci.HandleCommand(code.c_str(), eLazyBoolNo, result);

        if (saved_prompt_on_quit)
          ci.SetPromptOnQuit(true);

        if (result.GetStatus() == lldb::eReturnStatusQuit) {
          did_quit = true;
          io_handler.SetIsDone(true);
          if (debugger.CheckTopIOHandlerTypes(
                  IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter)) {
            // We typed "quit" or an alias to quit so we need to check if the
            // command interpreter is above us and tell it that it is done as
            // well
            // so we don't drop back into the command interpreter if we have
            // already
            // quit
            lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());
            if (io_handler_sp)
              io_handler_sp->SetIsDone(true);
          }
        }
      } else {
        // ":" was followed by no arguments, so push the LLDB command prompt
        if (debugger.CheckTopIOHandlerTypes(
                IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter)) {
          // If the user wants to get back to the command interpreter and the
          // command interpreter is what launched the REPL, then just let the
          // REPL exit and fall back to the command interpreter.
          io_handler.SetIsDone(true);
        } else {
          // The REPL wasn't launched the by the command interpreter, it is the
          // base IOHandler, so we need to get the command interpreter and
          lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());
          if (io_handler_sp) {
            io_handler_sp->SetIsDone(false);
            debugger.PushIOHandler(ci.GetIOHandler());
          }
        }
      }
    } else {
      // Unwind any expression we might have been running in case our REPL
      // expression crashed and the user was looking around
      if (m_dedicated_repl_mode) {
        Thread *thread = exe_ctx.GetThreadPtr();
        if (thread && thread->UnwindInnermostExpression().Success()) {
          thread->SetSelectedFrameByIndex(0, false);
          exe_ctx.SetFrameSP(thread->GetSelectedFrame());
        }
      }

      const bool colorize_err = error_sp->GetFile().GetIsTerminalWithColors();

      EvaluateExpressionOptions expr_options;
      expr_options.SetCoerceToId(m_varobj_options.use_objc);
      expr_options.SetUnwindOnError(m_command_options.unwind_on_error);
      expr_options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints);
      expr_options.SetKeepInMemory(true);
      expr_options.SetUseDynamic(m_varobj_options.use_dynamic);
      expr_options.SetTryAllThreads(m_command_options.try_all_threads);
      expr_options.SetGenerateDebugInfo(true);
      expr_options.SetREPLEnabled(true);
      expr_options.SetColorizeErrors(colorize_err);
      expr_options.SetPoundLine(m_repl_source_path.c_str(),
                                m_code.GetSize() + 1);
      if (m_command_options.timeout > 0)
        expr_options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
      else
        expr_options.SetTimeout(llvm::None);

      expr_options.SetLanguage(GetLanguage());

      PersistentExpressionState *persistent_state =
          m_target.GetPersistentExpressionStateForLanguage(GetLanguage());

      const size_t var_count_before = persistent_state->GetSize();

      const char *expr_prefix = nullptr;
      lldb::ValueObjectSP result_valobj_sp;
      Error error;
      lldb::ModuleSP jit_module_sp;
      lldb::ExpressionResults execution_results =
          UserExpression::Evaluate(exe_ctx, expr_options, code.c_str(),
                                   expr_prefix, result_valobj_sp, error,
                                   0,       // Line offset
                                   nullptr, // Fixed Expression
                                   &jit_module_sp);

      // CommandInterpreter &ci = debugger.GetCommandInterpreter();

      if (process_sp && process_sp->IsAlive()) {
        bool add_to_code = true;
        bool handled = false;
        if (result_valobj_sp) {
          lldb::Format format = m_format_options.GetFormat();

          if (result_valobj_sp->GetError().Success()) {
            handled |= PrintOneVariable(debugger, output_sp, result_valobj_sp);
          } else if (result_valobj_sp->GetError().GetError() ==
                     UserExpression::kNoResult) {
            if (format != lldb::eFormatVoid && debugger.GetNotifyVoid()) {
              error_sp->PutCString("(void)\n");
              handled = true;
            }
          }
        }

        if (debugger.GetPrintDecls()) {
          for (size_t vi = var_count_before, ve = persistent_state->GetSize();
               vi != ve; ++vi) {
            lldb::ExpressionVariableSP persistent_var_sp =
                persistent_state->GetVariableAtIndex(vi);
            lldb::ValueObjectSP valobj_sp = persistent_var_sp->GetValueObject();

            PrintOneVariable(debugger, output_sp, valobj_sp,
                             persistent_var_sp.get());
          }
        }

        if (!handled) {
          bool useColors = error_sp->GetFile().GetIsTerminalWithColors();
          switch (execution_results) {
          case lldb::eExpressionSetupError:
          case lldb::eExpressionParseError:
            add_to_code = false;
            LLVM_FALLTHROUGH;
          case lldb::eExpressionDiscarded:
            error_sp->Printf("%s\n", error.AsCString());
            break;

          case lldb::eExpressionCompleted:
            break;
          case lldb::eExpressionInterrupted:
            if (useColors) {
              error_sp->Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            error_sp->Printf("Execution interrupted. ");
            if (useColors)
              error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            error_sp->Printf("Enter code to recover and continue.\nEnter LLDB "
                             "commands to investigate (type :help for "
                             "assistance.)\n");
            break;

          case lldb::eExpressionHitBreakpoint:
            // Breakpoint was hit, drop into LLDB command interpreter
            if (useColors) {
              error_sp->Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            output_sp->Printf("Execution stopped at breakpoint.  ");
            if (useColors)
              error_sp->Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            output_sp->Printf("Enter LLDB commands to investigate (type help "
                              "for assistance.)\n");
            {
              lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());
              if (io_handler_sp) {
                io_handler_sp->SetIsDone(false);
                debugger.PushIOHandler(ci.GetIOHandler());
              }
            }
            break;

          case lldb::eExpressionTimedOut:
            error_sp->Printf("error: timeout\n");
            if (error.AsCString())
              error_sp->Printf("error: %s\n", error.AsCString());
            break;
          case lldb::eExpressionResultUnavailable:
            // Shoulnd't happen???
            error_sp->Printf("error: could not fetch result -- %s\n",
                             error.AsCString());
            break;
          case lldb::eExpressionStoppedForDebug:
            // Shoulnd't happen???
            error_sp->Printf("error: stopped for debug -- %s\n",
                             error.AsCString());
            break;
          }
        }

        if (add_to_code) {
          const uint32_t new_default_line = m_code.GetSize() + 1;

          m_code.SplitIntoLines(code);

          // Update our code on disk
          if (!m_repl_source_path.empty()) {
            lldb_private::File file(m_repl_source_path.c_str(),
                                    File::eOpenOptionWrite |
                                        File::eOpenOptionTruncate |
                                        File::eOpenOptionCanCreate,
                                    lldb::eFilePermissionsFileDefault);
            std::string code(m_code.CopyList());
            code.append(1, '\n');
            size_t bytes_written = code.size();
            file.Write(code.c_str(), bytes_written);
            file.Close();

            // Now set the default file and line to the REPL source file
            m_target.GetSourceManager().SetDefaultFileAndLine(
                FileSpec(m_repl_source_path, false), new_default_line);
          }
          static_cast<IOHandlerEditline &>(io_handler)
              .SetBaseLineNumber(m_code.GetSize() + 1);
        }
        if (extra_line) {
          fprintf(output_sp->GetFile().GetStream(), "\n");
        }
      }
    }

    // Don't complain about the REPL process going away if we are in the process
    // of quitting.
    if (!did_quit && (!process_sp || !process_sp->IsAlive())) {
      error_sp->Printf(
          "error: REPL process is no longer alive, exiting REPL\n");
      io_handler.SetIsDone(true);
    }
  }
}
コード例 #16
0
ファイル: IOSelect.cpp プロジェクト: MajorBreakfast/cvt
	int IOSelect::handleIO( ssize_t ms )
	{
		int maxfd = 0;
		int numfd, ret, active;

		if( _handlers.empty() )
			return 0;


		FD_ZERO( &_readfds );
		FD_ZERO( &_writefds );
		FD_ZERO( &_execeptfds );

		for( std::list<IOHandler*>::iterator it = _handlers.begin(), end = _handlers.end(); it != end; ++it ) {
			IOHandler* ioh = *it;
			if( ioh->_read || ioh->_write || ioh->_except ) {
				maxfd = Math::max( maxfd, ioh->_fd );
				if( ioh->_read )
					FD_SET( ioh->_fd, &_readfds );
				if( ioh->_write )
					FD_SET( ioh->_fd, &_writefds );
				if( ioh->_except )
					FD_SET( ioh->_fd, &_execeptfds );
			}
		}

		if( ms < 0 ) {
			ret = pselect( maxfd + 1, &_readfds, &_writefds, &_execeptfds, NULL, NULL );
		} else {
			msToTimespec( ms, _timeout );
			ret = pselect( maxfd + 1, &_readfds, &_writefds, &_execeptfds, &_timeout, NULL );
		}
		/* FIXME: do error handling */
		if( ret <= 0 )
			return ret;

		numfd = ret;

		for( std::list<IOHandler*>::iterator it = _handlers.begin(), end = _handlers.end(); it != end; ++it ) {
			IOHandler* ioh = *it;
			if( ioh->_read || ioh->_write || ioh->_except ) {
				active = 0;
				if( ioh->_read && FD_ISSET( ioh->_fd, &_readfds ) ) {
					ioh->onDataReadable();
					active = 1;
				}
				if( ioh->_write && FD_ISSET( ioh->_fd, &_writefds ) ) {
					ioh->onDataWriteable();
					active = 1;
				}
				if( ioh->_except && FD_ISSET( ioh->_fd, &_execeptfds ) ) {
					ioh->onException();
					active = 1;
				}
				numfd -= active;
				if( !numfd )
					break;
			}
		}

		return ret;
	}
コード例 #17
0
ファイル: Game.hpp プロジェクト: Grindl/SD6A2
	virtual bool keyDownEvent(unsigned char asKey){return m_IOHandler.KeyDownEvent(asKey);}
コード例 #18
0
void SetSettingCommand::execute(){
    Settings::set(option, value);
    if (option == BRIGHTNESS){
        io.setBrightness(value);
    }
}