예제 #1
0
filter default_filter_factory< CharT >::parse_argument(attribute_name const& name, string_type const& arg)
{
    typedef log::aux::encoding_specific< typename log::aux::encoding< char_type >::type > encoding_specific;
    const qi::real_parser< double, qi::strict_real_policies< double > > real_;

    filter f;
    const on_fp_argument< RelationT > on_fp(name, f);
    const on_integral_argument< RelationT > on_int(name, f);
    const on_string_argument< RelationT > on_str(name, f);

    const bool res = qi::parse
    (
        arg.c_str(), arg.c_str() + arg.size(),
        (
            real_[boost::log::as_action(on_fp)] |
            qi::long_[boost::log::as_action(on_int)] |
            qi::as< string_type >()[ +encoding_specific::print ][boost::log::as_action(on_str)]
        ) >> qi::eoi
    );

    if (!res)
        BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");

    return boost::move(f);
}
예제 #2
0
int CCommonFnc::SCSAT_SaveSamples(string_type filePath, SAMPLE_PLOT* pSample, int startOffset, int endOffset) {
    int     status = STAT_OK;
    
    MoveFile((LPCTSTR) filePath.c_str(), (LPCTSTR) (filePath + _CONV(".bak")).c_str());
    DeleteFile((LPCTSTR) filePath.c_str());
    // SAVE HEADER
	string_type tmp;
    pSample->measureInfo.formatToString(&tmp);
    CCommonFnc::File_AppendString(filePath, tmp);
    
    int samplesFileOffset = 0;
    if ((status = CCommonFnc::SCSAT_GetPowerSamplesFileOffset(filePath, &samplesFileOffset)) == STAT_OK) {
        if ((status = CCommonFnc::File_SaveMatrixIntFileOffset(samplesFileOffset, filePath, &(pSample->dataBlob), startOffset, endOffset, pSample->measureInfo.bSaveBinary)) == STAT_OK) {
            // store number of written samples
            if (endOffset == -1) endOffset = pSample->dataBlob.dwActLen;
            pSample->measureInfo.numSamples = endOffset - startOffset + 2;
			tmp = string_format(_CONV("%d"), pSample->measureInfo.numSamples);
            //tmp.Format("%d", pSample->measureInfo.numSamples);
            WritePrivateProfileString(SCSAT_MEASURE_SECTION.c_str(), SCSAT_MEASURE_NUMSAMPLES.c_str(), (LPCTSTR) tmp.c_str(), (LPCTSTR) filePath.c_str());
        }      
    }
    
    if (status == STAT_OK) {
        DeleteFile((LPCTSTR) (filePath + _CONV(".bak")).c_str());
    }

    return status;
}
예제 #3
0
inline winini_bundle::string_type winini_bundle::operator [](char_type const *name) const throw(std::out_of_range)
{
    static const char_type sentinel[] = FASTFORMAT_LITERAL_STRING("{5DDAADE5-5134-4734-ACB8-A6D0FA3BD0EA}-{D875F19B-8279-4c44-9517-F16366BC13E3}");

    ::SetLastError(0);

    char_type   result[1001];
    DWORD       dw = ::GetPrivateProfileString(
                                            m_iniSection.c_str()
                                        ,   name
                                        ,   sentinel
                                        ,   &result[0]
                                        ,   STLSOFT_NUM_ELEMENTS(result)
                                        ,   m_iniFileName.c_str());

    if(dw == STLSOFT_NUM_ELEMENTS(sentinel) - 1)    /* element not found */
    {
        if(0 == string_type::traits_type::compare(sentinel, result, stlsoft::minimum(size_t(dw), STLSOFT_NUM_ELEMENTS(sentinel) - 1)))
        {
            throw std::out_of_range("section/key combination does not exist in the given INI file");
        }
    }

    ::GetLastError();

    return string_type(result, dw);
}
예제 #4
0
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::construct(
    boost::log::aux::universal_path const& message_file_name,
    string_type const& target,
    string_type const& log_name,
    string_type const& source_name,
    event_log::registration_mode reg_mode)
{
    if (reg_mode != event_log::never)
    {
        aux::registry_params< char_type > reg_params;
        string_type file_name;
        log::aux::code_convert(message_file_name.string(), file_name);
        reg_params.event_message_file = file_name;
        reg_params.types_supported = DWORD(
            EVENTLOG_SUCCESS |
            EVENTLOG_INFORMATION_TYPE |
            EVENTLOG_WARNING_TYPE |
            EVENTLOG_ERROR_TYPE);
        aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
    }

    std::auto_ptr< implementation > p(new implementation());

    const char_type* target_unc = NULL;
    if (!target.empty())
        target_unc = target.c_str();

    HANDLE hSource = register_event_source(target_unc, source_name.c_str());
    if (!hSource)
        BOOST_LOG_THROW_DESCR(system_error, "Could not register event source");

    p->m_SourceHandle = hSource;

    m_pImpl = p.release();
}
예제 #5
0
  void TimestampConverter::set_input_format(string_type const& format)
  {
    this->InputFormat = format;

    typedef boost::posix_time::time_input_facet input_facet_t;
    input_facet_t* facet = new input_facet_t(format.c_str());
    this->InputBuf.imbue(std::locale(this->InputBuf.getloc(), facet));
  }
예제 #6
0
 client::client(const string_type & host, unsigned int port)
 {
   char err[ANET_ERR_LEN];
   socket_ = anetTcpConnect(err, const_cast<char*>(host.c_str()), port);
   if (socket_ == ANET_ERR) 
     throw connection_error(err);
   anetTcpNoDelay(NULL, socket_);
 }
예제 #7
0
typename default_filter_factory< CharT >::filter_type
default_filter_factory< CharT >::parse_argument(string_type const& name, string_type const& arg)
{
    filter_type filter;
    const bool full = bsc::parse(arg.c_str(), arg.c_str() + arg.size(),
        (
            bsc::strict_real_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_fp_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
            bsc::int_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_integral_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
            (+bsc::print_p)[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_string_argument< RelationT >, boost::cref(name), _1, _2, boost::ref(filter))]
        )
    ).full;

    if (!full || filter.empty())
        BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");

    return filter;
}
예제 #8
0
int CCommonFnc::BYTE_ConvertFromHexNumToByte(string_type hexNum, BYTE* pByte) {
    DWORD num = type_to_int((LPCTSTR) hexNum.c_str(), NULL, 16);

    if (num == 0xFF) *pByte = 0xFF;
    else *pByte = (BYTE) num & 0xFF;
    
    return STAT_OK;
}
예제 #9
0
int CCommonFnc::File_AppendString(string_type filePath, string_type data) {
	int             status = STAT_OK;
	ofstream_type file;
	file.open(filePath, std::fstream::out | std::fstream::app);

	if (file.is_open()) {
		file.write((LPCTSTR)data.c_str(), data.length());
		file.close();
	}
	else status = STAT_FILE_OPEN_FAIL;

	return status;
}
예제 #10
0
    //! The method sends the formatted message to the syslog host
    void send(syslog::level lev, string_type const& formatted_message)
    {
        if (!m_pSocket.get())
        {
            asio::ip::udp::endpoint any_local_address;
            m_pSocket.reset(new syslog_udp_socket(m_pService->m_IOService, m_Protocol, any_local_address));
        }

        m_pSocket->send_message(
            this->m_Facility | static_cast< int >(lev),
            m_pService->m_LocalHostName.c_str(),
            m_TargetHost,
            formatted_message.c_str());
    }
예제 #11
0
        void to_stream(T const& value)
        {
            std::locale loc = m_Stream.getloc();
            if (!std::has_facet< FacetT >(loc))
            {
                // Add the formatting facet
                std::auto_ptr< FacetT > facet(new FacetT(m_Format.c_str()));
                m_Stream.imbue(std::locale(loc, facet.get()));
                facet.release();
                loc = m_Stream.getloc();
            }

            // Perform formatting
            std::ostreambuf_iterator< char_type > osb_it(m_Stream);
            std::use_facet< FacetT >(loc).put(osb_it, m_Stream, m_Stream.fill(), value);
        }
예제 #12
0
		thread_callback()
			: window_handle_(0)
			, atom_(0)
			, identity_(sprig::str_cast<string_type>(boost::uuids::random_generator()()))
		{
			window_class_.cbSize = sizeof(WNDCLASSEX);							// 構造体のサイズ
			window_class_.style = 0;											// クラススタイル
			window_class_.lpfnWndProc = static_cast<WNDPROC>(&windowProcedure);	// ウィンドウプロシージャ
			window_class_.cbClsExtra = 0;										// 補足メモリブロックのサイズ
			window_class_.cbWndExtra = 0;										// 補足メモリブロックのサイズ
			window_class_.hInstance = ::GetModuleHandle(0);						// インスタンス
			window_class_.hIcon = 0;											// アイコン
			window_class_.hCursor = 0;											// カーソル
			window_class_.hbrBackground = 0;									// 背景色
			window_class_.lpszMenuName = 0;										// メニュー名
			window_class_.lpszClassName = identity_.c_str();					// クラス名
			window_class_.hIconSm = 0;											// 小さいアイコン
		}
예제 #13
0
int CCommonFnc::File_GetAvailableFileName(string_type baseFile, string_type* pFreeFileName) {
    int             status = STAT_OK;
    char_type            fileName[MAX_PATH];
	string_type          fileNameStr;
	char_type            drive[_MAX_DRIVE];
	char_type            dir[_MAX_DIR];
	char_type            fname[_MAX_FNAME];
	char_type            ext[_MAX_EXT];
	const char_type* help;
    DWORD           index = 1;

    // FIND FIRST FREE INDEX
	type_path_split(baseFile.c_str(), drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);
    index = 1;
	string_type zeroes = _CONV("0000");
    //sprintf_s(fileName, MAX_PATH, "%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
	fileNameStr = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);
	help = fileNameStr.c_str();
	type_copy(fileName, help);
    while (GetFileAttributes(fileName) != -1) {
        index++;
        if (index < 10) zeroes = _CONV("0000");
        else if (index < 100) zeroes = _CONV("000");
        else if (index < 1000) zeroes = _CONV("00");
        else if (index < 10000) zeroes = _CONV("0");
        else zeroes = _CONV("");
        //sprintf_s(fileName, MAX_PATH, "%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
		fileNameStr = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);
		help = fileNameStr.c_str();
		type_copy(fileName, help);
    }    
    // INDEX FOUND
    //pFreeFileName->Format("%s%s%s%s%d%s", drive, dir, fname, (LPCTSTR) zeroes.c_str(), index, ext);
	*pFreeFileName = string_format(_CONV("%s%s%s%s%d%s"), drive, dir, fname, (LPCTSTR)zeroes.c_str(), index, ext);

    return status;
}
예제 #14
0
    virtual OutItrT do_put_tm(OutItrT next,
                              std::ios_base& a_ios,
                              char_type fill_char,
                              const tm& tm_value,
                              string_type a_format) const
    {
      // update format string with custom names
      if (m_weekday_long_names.size()) {
        boost::algorithm::replace_all(a_format,
                                      long_weekday_format,
                                      m_weekday_long_names[tm_value.tm_wday]);
      }
      if (m_weekday_short_names.size()) {
        boost::algorithm::replace_all(a_format,
                                      short_weekday_format,
                                      m_weekday_short_names[tm_value.tm_wday]);

      }
      if (m_month_long_names.size()) {
        boost::algorithm::replace_all(a_format,
                                      long_month_format,
                                      m_month_long_names[tm_value.tm_mon]);
      }
      if (m_month_short_names.size()) {
        boost::algorithm::replace_all(a_format,
                                      short_month_format,
                                      m_month_short_names[tm_value.tm_mon]);
      }
      // use time_put facet to create final string
      const char_type* p_format = a_format.c_str();
      return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
                                                                       fill_char,
                                                                       &tm_value,
                                                                       p_format,
                                                                       p_format + a_format.size());
    }
예제 #15
0
int CCommonFnc::SCSAT_EnsureFileHeader(string_type filePath, SCSAT_MEASURE_INFO* pInfo) {
	int status = STAT_OK;
	char_type iniValue[MAX_INI_VALUE_CHAR];

	// CHECK IF HEADER EXISTS
    BOOL    bNewFormat = FALSE; 
    int     fileLength = 0;
	fstream_type file;
	file.open(filePath, std::fstream::in | std::fstream::out);
   
	if (file.is_open()) {
		char_type buffer[100];
        memset(buffer, 0, sizeof(buffer));
        file.read(buffer, 100);
		file.seekg(0, std::ios_base::end);
		//fileLength = file.tellg();
		file.seekg(0, std::ios_base::beg);
		string_type header = buffer; string_type part = header.substr(1, (int)SCSAT_MEASURE_SECTION.length());
		if (compareWithNoCase2(SCSAT_MEASURE_SECTION.c_str(), part.c_str()) == 0) bNewFormat = TRUE;
        //if (part.compareWithNoCase(SCSAT_MEASURE_SECTION) == 0) bNewFormat = TRUE;
        else bNewFormat = FALSE;

    	// WRITE IF NOT 
        if (!bNewFormat) {
			string_type tmp;
			if (pInfo->sampleUniqueID == 0) {
				CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID));
			}
            pInfo->formatToString(&tmp);
			file.seekg(0, std::ios_base::beg);
			file.seekp(0, std::ios_base::beg);
	        file.write(tmp.c_str(), tmp.length());
        }
        
        file.close();
    
		// if the sampleUniqueID is not present
		
		if(bNewFormat) {
			GetPrivateProfileString(SCSAT_MEASURE_SECTION.c_str(), SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), _CONV(""), iniValue, MAX_INI_VALUE_CHAR, (LPCTSTR) filePath.c_str());
			if (type_length(iniValue) == 0) {
				if (pInfo->sampleUniqueID == 0) {
				CCommonFnc::Sample_GenerateSampleUniqueID(&(pInfo->sampleUniqueID));
			    }
				string_type tmp;
				tmp = string_format(_CONV("%lld"), pInfo->sampleUniqueID);
				//tmp.AtlUtil::Format("%lld", pInfo->sampleUniqueID);
                WritePrivateProfileString(SCSAT_MEASURE_SECTION.c_str(),SCSAT_MEASURE_SAMPLEUNIQUEID.c_str(), tmp.c_str(), filePath.c_str());
			
			}	
		}
	}
	return status;
}
예제 #16
0
//Based on the example at https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx.
Process::id_type Process::open(const string_type &command, const string_type &path) {
  if(open_stdin)
    stdin_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stdout)
    stdout_fd=std::unique_ptr<fd_type>(new fd_type(NULL));
  if(read_stderr)
    stderr_fd=std::unique_ptr<fd_type>(new fd_type(NULL));

  Handle stdin_rd_p;
  Handle stdin_wr_p;
  Handle stdout_rd_p;
  Handle stdout_wr_p;
  Handle stderr_rd_p;
  Handle stderr_wr_p;

  SECURITY_ATTRIBUTES security_attributes;

  security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
  security_attributes.bInheritHandle = TRUE;
  security_attributes.lpSecurityDescriptor = nullptr;

  std::lock_guard<std::mutex> lock(create_process_mutex);
  if(stdin_fd) {
    if (!CreatePipe(&stdin_rd_p, &stdin_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdin_wr_p, HANDLE_FLAG_INHERIT, 0))
      return 0;
  }
  if(stdout_fd) {
    if (!CreatePipe(&stdout_rd_p, &stdout_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stdout_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }
  if(stderr_fd) {
    if (!CreatePipe(&stderr_rd_p, &stderr_wr_p, &security_attributes, 0) ||
        !SetHandleInformation(stderr_rd_p, HANDLE_FLAG_INHERIT, 0)) {
      return 0;
    }
  }

  PROCESS_INFORMATION process_info;
  STARTUPINFO startup_info;

  ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));

  ZeroMemory(&startup_info, sizeof(STARTUPINFO));
  startup_info.cb = sizeof(STARTUPINFO);
  startup_info.hStdInput = stdin_rd_p;
  startup_info.hStdOutput = stdout_wr_p;
  startup_info.hStdError = stderr_wr_p;
  if(stdin_fd || stdout_fd || stderr_fd)
    startup_info.dwFlags |= STARTF_USESTDHANDLES;

  string_type process_command=command;
#ifdef MSYS_PROCESS_USE_SH
  size_t pos=0;
  while((pos=process_command.find('\\', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\\\\\\");
    pos+=4;
  }
  pos=0;
  while((pos=process_command.find('\"', pos))!=string_type::npos) {
    process_command.replace(pos, 1, "\\\"");
    pos+=2;
  }
  process_command.insert(0, "sh -c \"");
  process_command+="\"";
#endif

  BOOL bSuccess = CreateProcess(nullptr, process_command.empty()?nullptr:&process_command[0], nullptr, nullptr, TRUE, 0,
                                nullptr, path.empty()?nullptr:path.c_str(), &startup_info, &process_info);

  if(!bSuccess) {
    CloseHandle(process_info.hProcess);
    CloseHandle(process_info.hThread);
    return 0;
  }
  else {
    CloseHandle(process_info.hThread);
  }

  if(stdin_fd) *stdin_fd=stdin_wr_p.detach();
  if(stdout_fd) *stdout_fd=stdout_rd_p.detach();
  if(stderr_fd) *stderr_fd=stderr_rd_p.detach();

  closed=false;
  data.id=process_info.dwProcessId;
  data.handle=process_info.hProcess;
  return process_info.dwProcessId;
}
 explicit matches_predicate(string_type const& operand) :
     m_operand(regex_type::compile(operand.c_str(), operand.size(), regex_type::ECMAScript | regex_type::optimize))
 {
 }
예제 #18
0
파일: form_part.hpp 프로젝트: Shumen/cgi
 const char_type* c_str() const { return value.c_str(); }
예제 #19
0
 /*!
  * Lexicographical comparison (greater ordering)
  *
  * \param that Comparand
  * \return \c true if this string is greater than the comparand, \c false otherwise
  */
 bool operator> (string_type const& that) const
 {
     return (compare_internal(m_pStart, m_Len, that.c_str(), that.size()) > 0);
 }
//
// Prints out a given logging string, error code and the descriptive representation of that error code
//
// Parameters:
//  [in]    strMsg          A given message to be printed out
//  [in]    eErr            The API status code
//
void CAsynchronousGrabDlg::Log( string_type strMsg, VmbErrorType eErr )
{
    strMsg += _TEXT( "..." ) + m_ApiController.ErrorCodeToMessage( eErr );
    m_ListLog.InsertString( 0, strMsg.c_str() );
}
//
// Prints out a given logging string
//
// Parameters:
//  [in]    strMsg          A given message to be printed out
//
void CAsynchronousGrabDlg::Log( string_type strMsg )
{
    m_ListLog.InsertString( 0, strMsg.c_str() );
}
예제 #22
0
파일: form_part.hpp 프로젝트: Shumen/cgi
 operator const char_type* () const { return value.c_str(); }
예제 #23
0
    /*! Extract time zone abbreviations for STD & DST as well
     * as the offsets for the time shift that occurs and how
     * much of a shift. At this time full time zone names are
     * NOT extracted so the abbreviations are used in their place */
    void calc_zone(const string_type& obj){
      const char_type empty_string[2] = {'\0'};
      stringstream_type ss(empty_string);
      typename string_type::const_pointer sit = obj.c_str(), obj_end = sit + obj.size();
      string_type l_std_zone_abbrev, l_dst_zone_abbrev;

      // get 'std' name/abbrev
      while(std::isalpha(*sit)){
        ss << *sit++;
      }
      l_std_zone_abbrev = ss.str();
      ss.str(empty_string);

      // get UTC offset
      if(sit != obj_end){
        // get duration
        while(sit != obj_end && !std::isalpha(*sit)){
          ss << *sit++;
        }
        base_utc_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
        ss.str(empty_string);

        // base offset must be within range of -12 hours to +14 hours
        if(base_utc_offset_ < time_duration_type(-12,0,0) ||
          base_utc_offset_ > time_duration_type(14,0,0))
        {
          boost::throw_exception(bad_offset(posix_time::to_simple_string(base_utc_offset_)));
        }
      }

      // get DST data if given
      if(sit != obj_end){
        has_dst_ = true;

        // get 'dst' name/abbrev
        while(sit != obj_end && std::isalpha(*sit)){
          ss << *sit++;
        }
        l_dst_zone_abbrev = ss.str();
        ss.str(empty_string);

        // get DST offset if given
        if(sit != obj_end){
          // get duration
          while(sit != obj_end && !std::isalpha(*sit)){
            ss << *sit++;
          }
          dst_offsets_.dst_adjust_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
          ss.str(empty_string);
        }
        else{ // default DST offset
          dst_offsets_.dst_adjust_ = posix_time::hours(1);
        }

        // adjustment must be within +|- 1 day
        if(dst_offsets_.dst_adjust_ <= time_duration_type(-24,0,0) ||
            dst_offsets_.dst_adjust_ >= time_duration_type(24,0,0))
        {
          boost::throw_exception(bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_)));
        }
      }
      // full names not extracted so abbrevs used in their place
      zone_names_ = time_zone_names(l_std_zone_abbrev, l_std_zone_abbrev, l_dst_zone_abbrev, l_dst_zone_abbrev);
    }
예제 #24
0
파일: safeformat.cpp 프로젝트: semenovf/jq
 PrintfState<string_type&, char_type> SPrintf(string_type& s, const string_type& format) {
     return PrintfState<string_type&, char_type>(s, format.c_str());
 }
예제 #25
0
void ThinConsole::SetWindowTitle(string_type const& title) {
	ExceptionCheck(SetConsoleTitle(title.c_str()), __FUNCTION__, __LINE__);
}
예제 #26
0
 explicit predicate(RelationT const& rel, string_type const& operand) :
     RelationT(rel),
     m_operand(regex_type::compile(operand.c_str(), operand.size(), regex_type::ECMAScript | regex_type::optimize))
 {
 }
예제 #27
0
//[ example_extension_app_launcher_consume
// The function consumes the log records that come from the frontend
void app_launcher::consume(logging::record_view const& rec, string_type const& command_line)
{
    std::system(command_line.c_str());
}
예제 #28
0
		size_type get(OtherString const& str) const {
			return boost::lexical_cast<size_type>(str.c_str() + std::wcslen(prefix_.c_str()));
		}