コード例 #1
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"kilo");}
コード例 #2
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"hecto");}
コード例 #3
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string symbol() {return u32string(1, U'k');}
コード例 #4
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string symbol() {return u32string(U"da");}
コード例 #5
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"deca");}
コード例 #6
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"milli");}
コード例 #7
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"centi");}
コード例 #8
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"micro");}
コード例 #9
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"nano");}
コード例 #10
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"pico");}
コード例 #11
0
ファイル: ratio_io.hpp プロジェクト: regnirpsj/dcs08961
 static u32string prefix()  {return u32string(U"femto");}
コード例 #12
0
ファイル: lexer_util.cpp プロジェクト: jarro2783/TransLucid
std::pair<bool, u32string>
build_escaped_characters
(
  Iterator& current,
  const Iterator& end
)
{
  std::string building;
  bool error = false;
  int to_read = 0;

  while (*current == '\\' && error == false)
  {
    ++current;
    char32_t c = *current;
    switch(c)
    {
      case 'U':
      to_read = 8;
      ++current;
      break;

      case 'u':
      to_read = 4;
      ++current;
      break;

      case 'x':
      to_read = 2;
      ++current;
      break;

      case 'n':
      building += "\n";
      ++current;
      break;

      case 'r':
      building += "\r";
      ++current;
      break;

      case 't':
      building += "\t";
      ++current;
      break;

      case '\'':
      building += "\'";
      ++current;
      break;

      case '\"':
      building += "\"";
      ++current;
      break;

      case '\\':
      building += "\\";
      ++current;
      break;

      default:
      //invalid control character
      error = true;
      break;
    }

    //read the requested number of characters
    std::string chars;
    if (to_read > 0)
    {
      while (to_read > 0 && current != end && *current != '\'')
      {
        c = *current;  
        if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'))
        {
          chars += c;
        }
        else
        {
          break;
        }
        --to_read;
        ++current;
      }
    }

    //if we didn't read everything then error
    if (to_read != 0)
    {
      error = true;
    }
    else
    {
      uint32_t value = 0;
      for (char c : chars)
      {
        if (c >= '0' && c <= '9')
        {
          value = value * 16 + (c - '0');
        }
        else
        {
          value = value * 16 + (c - 'A' + 10);
        }
      }

      //it was a byte if it was two characters, otherwise it was a whole
      //character
      if (chars.length() == 2)
      {
        building += char(value & 0xFF);
      }
      else
      {
        building += utf32_to_utf8(u32string(1, value));
      }
    }
  }

  u32string u32result = utf8_to_utf32(building);
  return std::make_pair(!error, u32result);
}