Example #1
0
 string get_value (string A) const {
   std::transform (A.begin(), A.end(), A.begin(), ::toupper);
   return A;
 };
Example #2
0
int Input::getGLFWkeyFromString(string n)
{
	transform(n.begin(), n.end(), n.begin(), ::toupper);
	if (n == "Q")
		return GLFW_KEY_Q;
	if (n == "W")
		return GLFW_KEY_W;
	if (n == "E")
		return GLFW_KEY_E;
	if (n == "R")
		return GLFW_KEY_R;
	if (n == "T")
		return GLFW_KEY_T;
	if (n == "Y")
		return GLFW_KEY_Y;
	if (n == "U")
		return GLFW_KEY_U;
	if (n == "I")
		return GLFW_KEY_I;
	if (n == "O")
		return GLFW_KEY_O;
	if (n == "P")
		return GLFW_KEY_P;

	if (n == "A")
		return GLFW_KEY_A;
	if (n == "S")
		return GLFW_KEY_S;
	if (n == "D")
		return GLFW_KEY_D;
	if (n == "F")
		return GLFW_KEY_F;
	if (n == "G")
		return GLFW_KEY_G;
	if (n == "H")
		return GLFW_KEY_H;
	if (n == "J")
		return GLFW_KEY_J;
	if (n == "K")
		return GLFW_KEY_K;
	if (n == "L")
		return GLFW_KEY_L;

	if (n == "Z")
		return GLFW_KEY_Z;
	if (n == "X")
		return GLFW_KEY_X;
	if (n == "C")
		return GLFW_KEY_C;
	if (n == "V")
		return GLFW_KEY_V;
	if (n == "B")
		return GLFW_KEY_B;
	if (n == "N")
		return GLFW_KEY_N;
	if (n == "M")
		return GLFW_KEY_J;

	if (n == "1")
		return GLFW_KEY_1;
	if (n == "2")
		return GLFW_KEY_2;
	if (n == "3")
		return GLFW_KEY_3;
	if (n == "4")
		return GLFW_KEY_4;
	if (n == "5")
		return GLFW_KEY_5;
	if (n == "6")
		return GLFW_KEY_6;
	if (n == "7")
		return GLFW_KEY_7;
	if (n == "8")
		return GLFW_KEY_8;
	if (n == "9")
		return GLFW_KEY_9;
	if (n == "0")
		return GLFW_KEY_0;

	if (n == "NUM1")
		return GLFW_KEY_KP_1;
	if (n == "NUM2")
		return GLFW_KEY_KP_2;
	if (n == "NUM3")
		return GLFW_KEY_KP_3;
	if (n == "NUM4")
		return GLFW_KEY_KP_4;
	if (n == "NUM5")
		return GLFW_KEY_KP_5;
	if (n == "NUM6")
		return GLFW_KEY_KP_6;
	if (n == "NUM7")
		return GLFW_KEY_KP_7;
	if (n == "NUM8")
		return GLFW_KEY_KP_8;
	if (n == "NUM9")
		return GLFW_KEY_KP_9;
	if (n == "NUM0")
		return GLFW_KEY_KP_0;

	if (n == "PERIOD" || n == ".")
		return GLFW_KEY_PERIOD;
	if (n == "COMMA" || n == ",")
		return GLFW_KEY_COMMA;
	if (n == "DASH" || n == "-")
		return SWE_KEY_DASH;
	if (n == "APOSTROPHE" || n == "'")
		return SWE_KEY_APOSTROPHE;
	if (n == "PLUS" || n == "+")
		return SWE_KEY_PLUS;
	if (n == "TAB")
		return GLFW_KEY_TAB;
	if (n == "SHIFT")
		return GLFW_KEY_LEFT_SHIFT;
	if (n == "CTRL")
		return GLFW_KEY_LEFT_CONTROL;
	if (n == "ALT")
		return GLFW_KEY_LEFT_ALT;
	if (n == "SPACE")
		return GLFW_KEY_SPACE;
	if (n == "ENTER")
		return GLFW_KEY_ENTER;

	if (n == "F1")
		return GLFW_KEY_F1;
	if (n == "F2")
		return GLFW_KEY_F2;
	if (n == "F3")
		return GLFW_KEY_F3;
	if (n == "F4")
		return GLFW_KEY_F4;
	if (n == "F5")
		return GLFW_KEY_F5;
	if (n == "F6")
		return GLFW_KEY_F6;
	if (n == "F7")
		return GLFW_KEY_F7;
	if (n == "F8")
		return GLFW_KEY_F8;
	if (n == "F9")
		return GLFW_KEY_F9;
	if (n == "F10")
		return GLFW_KEY_F10;
	if (n == "F11")
		return GLFW_KEY_F11;
	if (n == "F12")
		return GLFW_KEY_F12;

	if (n == "M1")
		return GLFW_MOUSE_BUTTON_1;
	if (n == "M2")
		return GLFW_MOUSE_BUTTON_2;
	if (n == "M3")
		return GLFW_MOUSE_BUTTON_3;
	if (n == "M4")
		return GLFW_MOUSE_BUTTON_4;
	if (n == "M5")
		return GLFW_MOUSE_BUTTON_5;
	if (n == "M6")
		return GLFW_MOUSE_BUTTON_6;
	if (n == "M7")
		return GLFW_MOUSE_BUTTON_7;
	if (n == "M8")
		return GLFW_MOUSE_BUTTON_8;

	if (n == "UP")
		return GLFW_KEY_UP;
	if (n == "DOWN")
		return GLFW_KEY_DOWN;
	if (n == "LEFT")
		return GLFW_KEY_LEFT;
	if (n == "RIGHT")
		return GLFW_KEY_RIGHT;

	return 0;
}
string toLowString(string tString)
{
    transform(tString.begin(), tString.end(), tString.begin(), ::tolower);
    return tString;
}
int MapPanel::Search(const string &str, const string &sub)
{
	auto it = search(str.begin(), str.end(), sub.begin(), sub.end(),
		[](char a, char b) { return toupper(a) == toupper(b); });
	return (it == str.end() ? -1 : it - str.begin());
}
Example #5
0
void CinReader::toUpperCase (string& s)
{
  transform(s.begin(), s.end(),  s.begin(), ::toupper);
}
Example #6
0
string lowerCase(string input)
{
    for (string::iterator it = input.begin(); it != input.end(); ++ it)
      *it = toupper(*it);
    return input;
}
Example #7
0
void StringUtils::ToUpper(string &str)
{
  transform(str.begin(), str.end(), str.begin(), ::toupper);
}
string switch_8(string line)
{
    string line_3, line_8;
    auto line_beg = line.begin();
    auto line_end = line.end();
    while(line_beg <= line_end)
    {
        ++line_beg;
        line_3 += *line_beg;
        ++line_beg;
        line_3 += *line_beg;
        ++line_beg;
        line_3 += *line_beg;
        cout << line_3 << endl;
        if(line_3 == "000")
            line_8 += "0";
        else if (line_3 == "001")
            line_8 += "1";
        else if (line_3 == "010")
            line_8 += "2";
        else if (line_3 == "011")
            line_8 += "3";
        else if (line_3 == "100")
            line_8 += "4";
        else if (line_3 == "101")
            line_8 += "5";
        else if (line_3 == "110")
            line_8 += "6";
        else if (line_3 == "111")
            line_8 += "7";
        cout << line_8 << endl;
        ++line_beg;
        line_3 = {'\0'};
    }
    /*for(auto line_beg = line_8.begin(); line_beg != line.end(); ++line_beg)
    {
    	switch(*line_beg){
    		case "000":
    			line_3 += '0';
    			break;
    		case "001":
    			line_3 += '1';
    			break;
    		case "010":
    			line_3 += '2';
    			break;
    		case "011":
    			line_3 += '3';
    			break;
    		case "100":
    			line_3 += '4';
    			break;
    		case "101":
    			line_3 += '5';
    			break;
    		case "110":
    			line_3 += '6';
    			break;
    		case "111":
    			line_3 += '7';
    			break;
    	}
    }*/
    /*for (auto i : line_8)
    {
    	if(i == "000")
    		line_3 += '0';
    	else if (i == "001")
    		line_3 += '1';
    	else if (i == "010")
    		line_3 += '2';
    	else if (i == "011")
    		line_3 += '3';
    	else if (i == "100")
    		line_3 += '4';
    	else if (i == "101")
    		line_3 += '5';
    	else if (i == "110")
    		line_3 += '6';
    	else if (i == "111")
    		line_3 += '7';
    	cout << line_3 << endl;
    }*/
    return line_8;
}
Example #9
0
string LeftStrip(string s) {
    s.erase(s.begin(), find_if(s.begin(), s.end(), [](char c) {
        return isspace(c)==0;
    }));
    return s;
}
Example #10
0
//--------------------------------------------------
ofBuffer::ofBuffer(const string & text)
:buffer(text.begin(),text.end())
,currentLine(end(),end()){
	buffer.resize(buffer.size()+1,0);
}
Example #11
0
	bool wordBreak(string s, unordered_set<string> &dict)
	{
		if(s.empty())
			return false;
		return word(s.begin(), s.end(), dict);
	}
Example #12
0
File: url.cpp Project: burner/vmime
void url::parse(const string& str)
{
	// Protocol
	const string::size_type protoEnd = str.find("://");
	if (protoEnd == string::npos) throw exceptions::malformed_url("No protocol separator");

	const string proto =
		utility::stringUtils::toLower(string(str.begin(), str.begin() + protoEnd));

	// Username/password
	string::size_type slashPos = str.find('/', protoEnd + 3);
	if (slashPos == string::npos) slashPos = str.length();

	string::size_type atPos = str.rfind('@', slashPos);
	string hostPart;

	string username;
	string password;

	if (proto == PROTOCOL_FILE)
	{
		// No user name, password and host part.
		slashPos = protoEnd + 3;
	}
	else
	{
		if (atPos != string::npos && atPos < slashPos)
		{
			const string userPart(str.begin() + protoEnd + 3, str.begin() + atPos);
			const string::size_type colonPos = userPart.find(':');

			if (colonPos == string::npos)
			{
				username = userPart;
			}
			else
			{
				username = string(userPart.begin(), userPart.begin() + colonPos);
				password = string(userPart.begin() + colonPos + 1, userPart.end());
			}

			hostPart = string(str.begin() + atPos + 1, str.begin() + slashPos);
		}
		else
		{
			hostPart = string(str.begin() + protoEnd + 3, str.begin() + slashPos);
		}
	}

	// Host/port
	const string::size_type colonPos = hostPart.find(':');

	string host;
	string port;

	if (colonPos == string::npos)
	{
		host = utility::stringUtils::trim(hostPart);
	}
	else
	{
		host = utility::stringUtils::trim(string(hostPart.begin(), hostPart.begin() + colonPos));
		port = utility::stringUtils::trim(string(hostPart.begin() + colonPos + 1, hostPart.end()));
	}

	// Path
	string path = utility::stringUtils::trim(string(str.begin() + slashPos, str.end()));
	string params;

	string::size_type paramSep = path.find_first_of('?');

	if (paramSep != string::npos)
	{
		params = string(path.begin() + paramSep + 1, path.end());
		path.erase(path.begin() + paramSep, path.end());
	}

	if (path == "/")
		path.clear();

	// Some sanity check
	if (proto.empty())
		throw exceptions::malformed_url("No protocol specified");
	else if (host.empty())
	{
		// Accept empty host (eg. "file:///home/vincent/mydoc")
		if (proto != PROTOCOL_FILE)
			throw exceptions::malformed_url("No host specified");
	}

	bool onlyDigit = true;

	for (string::const_iterator it = port.begin() ;
	     onlyDigit && it != port.end() ; ++it)
	{
		onlyDigit = parserHelpers::isDigit(*it);
	}

	if (!onlyDigit)
		throw exceptions::malformed_url("Port can only contain digits");

	std::istringstream iss(port);
	port_t portNum = 0;

	iss >> portNum;

	if (portNum == 0)
		portNum = UNSPECIFIED_PORT;

	// Extract parameters
	m_params.removeAllProperties();

	if (!params.empty())
	{
		string::size_type pos = 0;

		do
		{
			const string::size_type start = pos;

			pos = params.find_first_of('&', pos);

			const string::size_type equal = params.find_first_of('=', start);
			const string::size_type end =
				(pos == string::npos ? params.length() : pos);

			string name;
			string value;

			if (equal == string::npos || equal > pos) // no value
			{
				name = string(params.begin() + start, params.begin() + end);
				value = name;
			}
			else
			{
				name = string(params.begin() + start, params.begin() + equal);
				value = string(params.begin() + equal + 1, params.begin() + end);
			}

			name = urlUtils::decode(name);
			value = urlUtils::decode(value);

			m_params.setProperty(name, value);

			if (pos != string::npos)
				++pos;
		}
		while (pos != string::npos);
	}

	// Now, save URL parts
	m_protocol = proto;

	m_username = urlUtils::decode(username);
	m_password = urlUtils::decode(password);

	m_host = urlUtils::decode(host);
	m_port = portNum;

	m_path = urlUtils::decode(path);
}
Example #13
0
void myStrSort(string& str){
	sort( str.begin(), str.end() );
}
Example #14
0
// convert string s to upper case
string toUpperString(string s)
{
	transform(s.begin(), s.end(), s.begin(), ::toupper);
	return s;
}
Example #15
0
string Util::ToLower(string str) {
	transform(str.begin(), str.end(), str.begin(), (int (&)(int))tolower);return str;
}
Example #16
0
string RightStrip(string s) {
    s.erase(find_if(s.rbegin(), s.rend(), [](char c) {
        return isspace(c)==0;
    }).base(), s.end());
    return s;
}
Example #17
0
/* Rechercher les tags d'un produit */
vector<Produit*> GestionBdd::rechercherTags(string t){
    // Transformation des caractères du tag en minuscules
    std::transform(t.begin(), t.end(), t.begin(), ::tolower);
    return produits.rechercherTags(t);
}
Example #18
0
 bool isAnagram(string s, string t)
 {
     sort(s.begin(),s.end());
     sort(t.begin(),t.end());
     return s==t;
 }
Example #19
0
bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const {
  return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), ci_less);
}
Example #20
0
	String StringToWstring(const string& input) {
		return String(input.begin(), input.end());
	}
Example #21
0
void StringUtils::ToLower(string &str)
{
  transform(str.begin(), str.end(), str.begin(), ::tolower);
}
Example #22
0
 int numJewelsInStones(string J, string S) {
   unordered_set<char> jewels(J.begin(), J.end());
   int res = 0;
   for (const auto& stone : S) res += jewels.count(stone);
   return res;
 }
Example #23
0
string upper(string str){
    transform(str.begin(), str.end(), str.begin(), ::toupper);  
    return str;
}
Example #24
0
 void operator()(string& str)
 {
     for_each(str.begin(), str.end(), convertWord());
 }
Example #25
0
 // assignment operator
 void operator = ( string b ) { // assigns a string to Bigint
   a = b[0] == '-' ? b.substr(1) : b;
   reverse( a.begin(), a.end() );
   this->normalize( b[0] == '-' ? -1 : 1 );
 }
bool QueryEvaluator::isNumber(string s)
{
    std::string::const_iterator it = s.begin();
    while (it != s.end() && std::isdigit(*it)) ++it;
    return !s.empty() && it == s.end();
}
Example #27
0
u32string convertUtf8ToUtf32(const string& utf8string)
{
  u32string result;
  utf8::utf8to32(utf8string.begin(), utf8string.end(), back_inserter(result));
  return result;
}
bool Anagram1(string a, string b){				//order(nlogn)
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	return(a == b);	
}
string toUpString(string tString)
{
    transform(tString.begin(), tString.end(), tString.begin(), ::toupper);
    return tString;
}
Example #30
0
void recognize() {

	if (!JULIUS_DEBUG) jlog_set_output(NULL);

	running = TRUE;

	ROS_INFO("Julius rev. %s", JULIUS_VERSION);

	{

		std::vector<char> tmp(JULIUS_CONFIGURATION.begin(), JULIUS_CONFIGURATION.end());
		tmp.push_back(0);
		jconf = j_config_load_file_new(&tmp[0]);

	}
	if (jconf == NULL) {
		ROS_ERROR("Unable to read config file.\n");
		running = FALSE;
		return;
	}
  
	jconf->input.speech_input = SP_MIC;

	recog = j_create_instance_from_jconf(jconf);
	if (recog == NULL) {
		ROS_ERROR("Julius startup error.");
		running = FALSE;
		return;
	}

	/*********************/
	/* Register callback */
	/*********************/
	/* register result callback functions */
	callback_add(recog, CALLBACK_EVENT_SPEECH_READY, status_recready, NULL);
	callback_add(recog, CALLBACK_EVENT_SPEECH_START, status_recstart, NULL);
	callback_add(recog, CALLBACK_RESULT, output_result, NULL);
  callback_add(recog, CALLBACK_PAUSE_FUNCTION, status_paused_wait, NULL);

	/**************************/
	/* Initialize audio input */
	/**************************/
	/* initialize audio input device */
	/* ad-in thread starts at this time for microphone */
	if (j_adin_init(recog) == FALSE) {   
		ROS_ERROR("Failed to initialize audio input.");
		running = FALSE;
		return;
	}

  if (JULIUS_DEBUG) j_recog_info(recog);

	switch(j_open_stream(recog, NULL)) {
		case 0:	
			break;
		case -1:  
			ROS_ERROR("Error in audio input stream.");
			running = FALSE;
			return;
		case -2:
			ROS_ERROR("Failed to start audio input stream.");
			running = FALSE;
			return;
	}

	if (j_recognize_stream(recog) == -1) 
		ROS_ERROR("Speech recognition error.");

	j_close_stream(recog);

	j_recog_free(recog);

	recog = NULL;

	running = FALSE;

}