Пример #1
0
			static std::deque<string_type> tokenize(string_type input, string_type br)
			{
				typename string_type::iterator a,b,c;
				std::deque<string_type> tokens;

				// std::cerr << "Tokenising string=" << input << " break=" << br << std::endl;

				while ( input.length() )
				{
					a = input.begin();
					c = input.end();
					typename string_type::size_type e = input.find(br);

					if ( e != string_type::npos )
					{
						b = a+e;
						tokens.push_back(string_type(a,b));
						input = string_type(b+br.length(),c);
					}
					else
					{
						tokens.push_back(input);
						input = string_type();
					}

					// std::cerr << "Pushed token " << tokens.back() << " input now " << input << std::endl;
				}

				return tokens;
			}
Пример #2
0
 /// Returns a copy of the string fmt. For each format specifier or escape sequence in fmt,
 /// replace that sequence with either the character(s) it represents, or the sequence within
 /// *this to which it refers. The bitmasks specified in flags determines what format specifiers
 /// or escape sequences are recognized, by default this is the format used by ECMA-262,
 /// ECMAScript Language Specification, Chapter 15 part 5.4.11 String.prototype.replace.
 string_type format(const string_type &fmt, regex_constants::match_flag_type flags = regex_constants::format_default) const
 {
     string_type result;
     result.reserve(fmt.length() * 2);
     this->format(std::back_inserter(result), fmt, flags);
     return result;
 }
Пример #3
0
/** \brief Verify the operator prototype.

  Binary operators have the additional constraint that return type and the types
  of both arguments must be the same. So adding to floats can not produce a string
  and adding a number to a string is impossible.
*/
void IOprtBin::CheckPrototype(const string_type &a_sProt)
{
    if (a_sProt.length()!=4)
        throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );

    //if (a_sProt[0]!=a_sProt[2] || a_sProt[0]!=a_sProt[3])
    //  throw ParserError( ErrorContext(ecAPI_INVALID_PROTOTYPE, -1, GetIdent() ) );
}
Пример #4
0
 bool is_kept(Char E) const
 {
   if (m_kept_delims.length())
     return m_kept_delims.find(E) != string_type::npos;
   else if (m_use_ispunct) {
     return Traits::ispunct(E) != 0;
   } else
     return false;
 }
Пример #5
0
 bool is_dropped(Char E) const
 {
   if (m_dropped_delims.length())
     return m_dropped_delims.find(E) != string_type::npos;
   else if (m_use_isspace) {
     return Traits::isspace(E) != 0;
   } else
     return false;
 }
Пример #6
0
EntryType SevenZipFileEntry::getEntryType(const string_type& path) const
{
	if (path.length() == 0)
	{
		// Special case: The root entry is always a directory
		return DIRECTORY;
	}

	return parentSystem->getFileData(path).type;
}
Пример #7
0
 /** \brief Check if a given name contains invalid characters. 
     \param a_strName The name to check
     \param a_szCharSet The characterset
     \throw ParserException if the name contains invalid charakters.
 */
 void ParserXBase::CheckName(const string_type &a_strName, 
                             const string_type &a_szCharSet) const
 {
   if ( !a_strName.length() || 
       (a_strName.find_first_not_of(a_szCharSet)!=string_type::npos) ||
       (a_strName[0]>=(char_type)'0' && a_strName[0]<=(char_type)'9'))
   {
     Error(ecINVALID_NAME);
   }
 }
Пример #8
0
void stringProxy::set(const string_type& s, const size_type start, const size_type end)
{
	m_buffer = s;
	m_start = start;

	if (end == std::numeric_limits <size_type>::max())
		m_end = s.length();
	else
		m_end = end;
}
Пример #9
0
 bool is_dropped(Char E) const
 {
   if (m_dropped_delims.length())
     return m_dropped_delims.find(E) != string_type::npos;
   else if (m_use_isspace) {
     using namespace std; 
     return isspace(E) != 0;
   } else
     return false;
 }
Пример #10
0
 bool is_kept(Char E) const
 {  
   if (m_kept_delims.length())
     return m_kept_delims.find(E) != string_type::npos;
   else if (m_use_ispunct) {
     using namespace std;
     return ispunct(E) != 0;
   } else
     return false;
 }
Пример #11
0
    /// Evaluates whether the contents of the two sequences are equivalent to the given extent
    static ss_bool_t is_equal_(string_type const& lhs, ss_typename_type_k string_type::value_type const* rhs)
    {
        { for(ss_size_t i = 0, n = lhs.length(); i < n; ++i)
        {
            if(lhs[i] != rhs[i])
            {
                return false;
            }
        }}

        return true;
    }
Пример #12
0
 bool is_nonret(Char E)const
 {
   if (nonreturnable_.length())
     return  nonreturnable_.find(E) != string_type::npos;
   else{
     if (no_isspace_) {return false;}
     else{
       int r = Traits::isspace(E);
       return r != 0;
     }
   }
 }
Пример #13
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;
}
Пример #14
0
 bool is_ret(Char E)const
 {  
   if (returnable_.length())
     return  returnable_.find(E) != string_type::npos;
   else{
     if (no_ispunct_) {return false;}
     else{
       using namespace std;
       int r = ispunct(E);
       return r != 0;
     }
   }
 }
Пример #15
0
string_type neighbor(const string_type & hash_string, const int direction [])
{
    // Adjust the DecodedHash for the direction of the neighbors
    DecodedHash lonlat = decode(hash_string);
    lonlat.latitude   += direction[0] * lonlat.latitude_err * 2;
    lonlat.longitude  += direction[1] * lonlat.longitude_err * 2;

    string_type output;
    encode(
        lonlat.latitude,
        lonlat.longitude,
        hash_string.length(),
        output);
    return output;
}
Пример #16
0
 //! throws ios_base::failure if delimiter and parsed data do not match
 void consume_delim(stream_itr_type& sitr,
                    stream_itr_type& stream_end,
                    const string_type& delim) const
 {
   /* string_parse_tree will not parse a string of punctuation characters 
    * without knowing exactly how many characters to process
    * Ex [2000. Will not parse out the '[' string without knowing 
    * to process only one character. By using length of the delimiter 
    * string we can safely iterate past it. */
   string_type s;
   for(unsigned int i = 0; i < delim.length() && sitr != stream_end; ++i) {
     s += *sitr;
     ++sitr;
   }
   if(s != delim) {
     throw std::ios_base::failure("Parse failed. Expected '" + convert_string_type<char_type,char>(delim) + "' but found '" + convert_string_type<char_type,char>(s) + "'");
   }
 }
Пример #17
0
  /** \brief Replace all occurrences of a substring with another string. 
      \param strFind The string that shall be replaced.
      \param strReplaceWith The string that should be inserted instead of strFind
  */
  void ParserError::ReplaceSubString( string_type &strSource,
                                      const string_type &strFind,
                                      const string_type &strReplaceWith)
  {
    string_type strResult;
    string_type::size_type iPos(0), iNext(0);

    for(;;)
    {
      iNext = strSource.find(strFind, iPos);
      strResult.append(strSource, iPos, iNext-iPos);

      if( iNext==string_type::npos )
        break;

      strResult.append(strReplaceWith);
      iPos = iNext + strFind.length();
    } 

    strSource.swap(strResult);
  }
Пример #18
0
stringProxy::stringProxy(const string_type& s, const size_type start, const size_type end)
	: m_buffer(s), m_start(start),
	  m_end(end == std::numeric_limits <size_type>::max() ? s.length() : end)
{
}
Пример #19
0
 /// Returns the length of the delimiter
 static ss_size_t get_length_(string_type const& s)
 {
     return s.length();
 }
Пример #20
0
int CCommonFnc::BYTE_ConvertFromHexStringToArray(string_type hexaString, BYTE* pArray, DWORD* pbArrayLen) {
    int         status = STAT_OK;
    DWORD       pos = 0;
    DWORD       pos2 = 0;
	string_type     hexNum;
    DWORD       num;
    BYTE*       pTempArray = NULL;
    DWORD       tempArrayPos = 0;

    // EAT SPACES
    //hexaString.TrimLeft(); hexaString.TrimRight();
	hexaString.erase(hexaString.find_last_not_of(_CONV(" ")) + 1);
	size_t startpos = hexaString.find_first_not_of(_CONV(" "));
	if (string_type::npos != startpos) {
		hexaString = hexaString.substr(startpos);
	}
    hexaString += _CONV(" ");
    hexaString.length();

    if (status == STAT_OK) {
        pTempArray = new BYTE[hexaString.length()];
        memset(pTempArray, 0, hexaString.length());

        pos = pos2 = 0;
        /*while ((pos = hexaString.Find(' ', pos2)) != -1) {
            hexNum = hexaString.Mid(pos2, pos - pos2);
            hexNum.TrimLeft(); hexNum.TrimRight();
            if (hexNum.GetLength() > 0) {
                num = strtol((LPCTSTR) hexNum, NULL, 16);
        
                if (num == 0xFF) pTempArray[tempArrayPos] = 0xFF;
                else pTempArray[tempArrayPos] = (BYTE) num & 0xFF;
                
                tempArrayPos++;
            }
            pos2 = pos + 1;
        }*/
		while ((pos = hexaString.find(' ', pos2)) != string_type::npos) {
			hexNum = hexaString.substr((pos2, pos - pos2));
			hexNum.erase(hexNum.find_last_not_of(_CONV(" ")) + 1);
			size_t startpos2 = hexNum.find_first_not_of(_CONV(" "));
			if (string_type::npos != startpos2) {
				hexNum = hexNum.substr(startpos2);
			}
			if (hexNum.length() > 0) {
				num = type_to_int((LPCTSTR)hexNum.c_str(), NULL, 16);

				if (num == 0xFF) pTempArray[tempArrayPos] = 0xFF;
				else pTempArray[tempArrayPos] = (BYTE)num & 0xFF;

				tempArrayPos++;
			}
			pos2 = pos + 1;
		}

        if (tempArrayPos > *pbArrayLen) {
            status = STAT_NOT_ENOUGHT_MEMORY;
        }  
        else {
            memcpy(pArray, pTempArray, tempArrayPos);
        }
        *pbArrayLen = tempArrayPos;

        if (pTempArray) delete[] pTempArray;
    }

    return status;
}