コード例 #1
0
ファイル: config_file.cpp プロジェクト: chinarustin/aep
/* static */
void ConfigFile::trim( wstring& s )
{
	// Remove leading and trailing whitespace
	static const wchar_t whitespace[] = L" \n\t\v\r\f";
	s.erase( 0, s.find_first_not_of(whitespace) );
	s.erase( s.find_last_not_of(whitespace) + 1U );
}
コード例 #2
0
ファイル: bserv.cpp プロジェクト: kitserver/kitserver8
static void string_strip(wstring& s)
{
    static const wchar_t* empties = L" \t\n\r";
    int e = s.find_last_not_of(empties);
    s.erase(e + 1);
    int b = s.find_first_not_of(empties);
    s.erase(0,b);
}
コード例 #3
0
ファイル: StrConvert.cpp プロジェクト: tianyx/TxUIProject
void RTrim( wstring& wsInOut )
{
	size_t nPos = wsInOut.find_last_not_of(L" \n\r\t");
	if (nPos!= wstring::npos)
	{
		wsInOut = wsInOut.substr(0, nPos+1); 
	}
}
コード例 #4
0
ファイル: Helpers.cpp プロジェクト: Baron59/boss
	wstring Tidy(wstring filename) {						//Changes uppercase to lowercase and removes trailing spaces to do what Windows filesystem does to filenames.	
		size_t endpos = filename.find_last_not_of(L" \t");
	
		if (filename.npos == endpos) return (L""); 			//sanity check for empty string
		else {
			filename = filename.substr(0, endpos+1);
			for (unsigned int i = 0; i < filename.length(); i++) filename[i] = tolower(filename[i]);
			return (filename);
		}
	}
コード例 #5
0
void trim(wstring& str) {
    wstring::size_type pos = str.find_last_not_of(' ');
    if(pos != string::npos) {
        str.erase(pos + 1);
        pos = str.find_first_not_of(' ');
        if(pos != string::npos) 
            str.erase(0, pos);
    }
    else 
        str.erase(str.begin(), str.end());
}
コード例 #6
0
ファイル: StrConvert.cpp プロジェクト: tianyx/TxUIProject
void RTrim( wstring& wsInOut , LPCWSTR lpChars)
{
	if (lpChars == NULL || lpChars[0] == '\0')
	{
		return;
	}
	size_t nPos = wsInOut.find_last_not_of(lpChars);
	if (nPos!= wstring::npos)
	{
		wsInOut.substr(0,nPos); 
	}
}
コード例 #7
0
ファイル: StringUtility.cpp プロジェクト: bzquan/CucumberCpp
wstring StringUtility::Trim(const wstring& wstr)
{
    const wchar_t* WHITE_SPACES = L" \t";

    wstring result;
    wstring::size_type left = wstr.find_first_not_of(WHITE_SPACES);
    if (left != wstring::npos)
    {
        wstring::size_type right = wstr.find_last_not_of(WHITE_SPACES);
        result = wstr.substr(left, right - left + 1);
    }

    return FilterQuotations(result);
}
コード例 #8
0
ファイル: string.cpp プロジェクト: vjcagay/taiga
void Trim(wstring& str, const wchar_t trim_chars[],
          bool trim_left, bool trim_right) {
  if (str.empty())
    return;

  const size_t index_begin =
      trim_left ? str.find_first_not_of(trim_chars) : 0;
  const size_t index_end =
      trim_right ? str.find_last_not_of(trim_chars) : str.length() - 1;

  if (index_begin == wstring::npos || index_end == wstring::npos) {
    str.clear();
    return;
  }

  if (trim_right)
    str.erase(index_end + 1, str.length() - index_end + 1);
  if (trim_left)
    str.erase(0, index_begin);
}
コード例 #9
0
void OIFReader::ReadOifLine(wstring oneline)
{
   //process
   if (oneline.substr(0, 6) == L"[Axis ")
   {
      axis_num++;
   }
   else
   {
      if (axis_num > -1)
      {
         size_t pos = oneline.find(L'=');
         wstring str1 = oneline.substr(0, oneline.find_last_not_of(L' ', pos));
         wstring str2 = oneline.substr(oneline.find_first_not_of(L' ', pos+1));

         if (str1 == L"AxisCode")
         {
            if (cur_axis != axis_num)
            {
               cur_axis = axis_num;
               axis_code.clear();
               pix_unit.clear();
               max_size.clear();
               start_pos.clear();
               end_pos.clear();
            }
            axis_code = str2;
         }
         else if (str1 == L"PixUnit")
         {
            if (cur_axis != axis_num)
            {
               cur_axis = axis_num;
               axis_code.clear();
               pix_unit.clear();
               max_size.clear();
               start_pos.clear();
               end_pos.clear();
            }
            pix_unit = str2;
         }
         else if (str1 == L"MaxSize")
         {
            if (cur_axis != axis_num)
            {
               cur_axis = axis_num;
               axis_code.clear();
               pix_unit.clear();
               max_size.clear();
               start_pos.clear();
               end_pos.clear();
            }
            max_size = str2;
         }
         else if (str1 == L"StartPosition")
         {
            if (cur_axis != axis_num)
            {
               cur_axis = axis_num;
               axis_code.clear();
               pix_unit.clear();
               max_size.clear();
               start_pos.clear();
               end_pos.clear();
            }
            start_pos = str2;
         }
         else if (str1 == L"EndPosition")
         {
            if (cur_axis != axis_num)
            {
               cur_axis = axis_num;
               axis_code.clear();
               pix_unit.clear();
               max_size.clear();
               start_pos.clear();
               end_pos.clear();
            }
            end_pos = str2;
         }
      }
   }
   if (oneline.substr(0, 9) == L"[Channel ")
   {
	  light_type.clear();
      chan_num++;
   }
   else
   {
      if (chan_num > -1)
      {
         size_t pos = oneline.find(L'=');
         wstring str1 = oneline.substr(0, oneline.find_last_not_of(L' ', pos));
         wstring str2 = oneline.substr(oneline.find_first_not_of(L' ', pos+1));
		 wstring str3 = L"Transmitted Light";
		 if (str1 == L"LightType") {
			 light_type = str2;
			 if (light_type.find(str3) != wstring::npos) {
				 for (int i = m_excitation_wavelength_list.size() -1; i >=0; i--) {
					 if (m_excitation_wavelength_list.at(i).chan_num == cur_chan) {
						 m_excitation_wavelength_list.at(i).wavelength = -1;
						 break;
					 }
				 }
			 }
		  }
         else if (str1 == L"ExcitationWavelength")
         {
            if (cur_chan != chan_num)
            {
               cur_chan = chan_num;
               WavelengthInfo info;
               info.chan_num = cur_chan;
               info.wavelength = WSTOD(str2);
				if (light_type == L"Transmitted Light") 
					info.wavelength = -1;
               m_excitation_wavelength_list.push_back(info);
            }
         }
      }
   }

   //axis
   if (!axis_code.empty() &&
         !pix_unit.empty() &&
         !max_size.empty() &&
         !start_pos.empty() &&
         !end_pos.empty())
   {
      //calculate
      double spc = 0.0;
      double dmax = WSTOD(max_size);
      if (dmax > 0.0)
         spc= fabs((WSTOD(end_pos)-
                  WSTOD(start_pos)))/
            dmax;
      if ((int64_t)pix_unit.find(L"nm")!=-1)
         spc /= 1000.0;
      if ((int64_t)axis_code.find(L"X")!=-1)
      {
         m_x_size = WSTOI(max_size);
         m_xspc = spc;
      }
      else if ((int64_t)axis_code.find(L"Y")!=-1)
      {
         m_y_size = WSTOI(max_size);
         m_yspc = spc;
      }
      else if ((int64_t)axis_code.find(L"Z")!=-1)
         m_zspc = spc;

      axis_code.clear();
      pix_unit.clear();
      max_size.clear();
      start_pos.clear();
      end_pos.clear();
   }
}
コード例 #10
0
wstring TrimRightW(const wstring& str)
{
	size_t n = str.find_last_not_of(L" \t\v");
	return (n == wstring::npos) ? str : str.substr(0, n + 1);
} 
コード例 #11
0
ファイル: ToolChain.cpp プロジェクト: xmoeproject/X-moe
void TrimW(wstring& s)
{
	const wstring DropChar = L" ";
	s.erase(s.find_last_not_of(DropChar)+1);
	s.erase(0, s.find_first_not_of(DropChar));
}
コード例 #12
0
/**
 * Returns a wstring that is the same as "str", but with any L'\n' characters at
 * the end removed.
 */
static wstring stripTrailingNewlines(wstring str) {
    return str.substr(0, str.find_last_not_of(L'\n') + 1);
}