コード例 #1
0
ファイル: Options.cpp プロジェクト: aakoshh/StataDwPlugin
// parse a STATA command 
DwUseOptions* DwUseOptionParser::Parse(vector<string> words) {	

	// there are 10 keywords we expect to see
	string keys[] = {"variables", "if", "using", "limit",
					 "nulldata", "lowercase", "uppercase", 
					 "label_variable", "label_values", 
					 "username", "password", "database"};
	size_t nkeys(sizeof(keys) / sizeof(string));
	// create parser that accepts these keywords
	OptionParser* parser = new OptionParser( set<string>(keys, keys + nkeys) );

	// prepare another vector where we can search 

	// see if we have a using anywhere, if we do, the first part is the varlist, if not it is the tablename
	bool hasUsing = hasKeyword(words, "using");

	// if it contains using somewhere we can start with variables (if missing it will be an empty string, if the list is there it will be expected)
	if( !hasUsing ) 
		words.insert(words.begin(), "using"); 
	else if( lowerCase(words[0]) != "if" && lowerCase(words[0]) != "using" )
		words.insert(words.begin(), "variables");

	// parse the options
	map<string,string> options = parser->Parse( words );
	delete parser;

	// create a meaningful options object
	DwUseOptions* useOptions = new DwUseOptions( options );	
	return useOptions;
}
コード例 #2
0
ファイル: sdp.cpp プロジェクト: Undev/crtmpserver
bool SDP::ParseSDPLineA(string &attributeName, Variant &value, string line) {
	string::size_type pos = line.find(':');
	if ((pos == string::npos)
			|| (pos == 0)
			|| (pos == (line.size() - 1))) {
		attributeName = line;
		value = (bool)true;
		return true;
	}

	attributeName = line.substr(0, pos);
	string rawValue = line.substr(line.find(':') + 1);
	if (attributeName == "control") {
		value = rawValue;
		return true;
	} else if (attributeName == "maxprate") {
		value = (double) strtod(STR(rawValue), NULL);
		return true;
	} else if (attributeName.find("x-") == 0) {
		value = rawValue;
		return true;
	} else if (attributeName == "rtpmap") {
		//rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding parameters>]
		vector<string> parts;
		split(rawValue, " ", parts);
		if (parts.size() != 2)
			return false;
		value["payloadType"] = (uint8_t) atoi(STR(parts[0]));
		split(parts[1], "/", parts);
		if ((parts.size() != 2) && (parts.size() != 3))
			return false;
		value["encodingName"] = parts[0];
		if (lowerCase((string) value["encodingName"]) == "h264") {
			value["encodingName"] = (uint64_t) CODEC_VIDEO_AVC;
		} else if ((string) lowerCase(value["encodingName"]) == "mpeg4-generic") {
			value["encodingName"] = (uint64_t) CODEC_AUDIO_AAC;
		} else {
			WARN("Invalid codec");
			value.Reset();
			return true;
		}
		value["clockRate"] = (uint32_t) atoi(STR(parts[1]));
		if (parts.size() == 3) {
			value["encodingParameters"] = parts[2];
		}

		return true;
	} else if (attributeName == "fmtp") {
		replace(rawValue, "; ", ";");
		vector<string> parts;
		split(rawValue, " ", parts);
		if (parts.size() != 2)
			return false;
		value["payloadType"] = (uint8_t) atoi(STR(parts[0]));
		map<string, string> temp = mapping(parts[1], ";", "=", false);

		FOR_MAP(temp, string, string, i) {
			value[MAP_KEY(i)] = MAP_VAL(i);
		}
コード例 #3
0
ファイル: Options.cpp プロジェクト: aakoshh/StataDwPlugin
bool hasKeyword(vector<string> words, string word) {
	for( size_t i=0; i < words.size(); i++ ) {
		if( lowerCase(words[i]) == lowerCase(word) ) {
			return true;
		}
	}
	return false;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: xiaolukuan/Htmltest
string parse_url (const char *charg) 
{
 	if(!charg)
 		return "";
 	int deb = 0, fin = deb;
 	char *arg = new char[strlen(charg)+1];
	char *argtmp = arg;
 	strcpy(arg,charg);
 	if(startWith("http://",arg))
 		arg += 7;
 	while (arg[fin] != '/' && arg[fin] != ':' && arg[fin] != 0) {
 		fin++;
 	}
 	if (fin == 0) 
 		return "";
 	char *host = new char[fin+1];
 	for (int  i=0; i<fin; i++) {
 		host[i] = lowerCase(arg[i]);
 	}
 	host[fin] = 0;
 	string strhost = host;
    delete [] argtmp;
	arg = NULL;
	argtmp = NULL;
 	delete [] host;
 	host = NULL;
 	return strhost;
}
コード例 #5
0
ファイル: Duration.cpp プロジェクト: SEJeff/task
bool Duration::valid (const std::string& input)
{
  std::string lower_input = lowerCase (input);

  // Assume the ordinal is 1, but look for an integer, just in case.
  double value = 1;
  Nibbler n (lower_input);
  n.getNumber (value);

  if (value < 0.0)
    value = -value;

  std::string units;
  n.getUntilEOS (units);

  // Non-trivial value with no units means the duration is specified in
  // seconds, and therefore a time_t.  Consider it valid.
  if (value != 0.0 &&
      units == "")
    return true;

  // Auto complete against all supported durations.
  std::vector <std::string> supported;
  for (unsigned int i = 0; i < NUM_DURATIONS; ++i)
    supported.push_back (durations[i]);

  std::vector <std::string> matches;
  if (autoComplete (units,
                    supported,
                    matches,
                    context.config.getInteger ("abbreviation.minimum")) == 1)
    return true;

  return false;
}
コード例 #6
0
bool CCTextureASTC::initWithContentsOfFile(const char* path)
{
    int len = 0;
    std::string lowerCase(path);
    if (lowerCase.find(".ccz") != std::string::npos)
    {
        len = ZipUtils::ccInflateCCZFile(path, &m_data);
    }
    else if (lowerCase.find(".gz") != std::string::npos)
    {
        len = ZipUtils::ccInflateGZipFile(path, &m_data);
    }
    else
    {
        m_data = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&len));
    }
    if(len<0){
        this->release();
        return false;
    }
    m_uName = 0;
    m_uWidth = m_uHeight = 0;
    if (!unpackData(m_data) ||!createGLTexture())
    {
        this->release();
        return false;
    }
    
    return true;
}
コード例 #7
0
string unhex(string source) {
	if (source == "")
		return "";
	if ((source.length() % 2) != 0) {
		FATAL("Invalid hex string: %s", STR(source));
		return "";
	}
	source = lowerCase(source);
	string result = "";
	for (uint32_t i = 0; i < (source.length() / 2); i++) {
		uint8_t val = 0;
		if ((source[i * 2] >= '0') && (source[i * 2] <= '9')) {
			val = (source[i * 2] - '0') << 4;
		} else if ((source[i * 2] >= 'a') && (source[i * 2] <= 'f')) {
			val = (source[i * 2] - 'a' + 10) << 4;
		} else {
			FATAL("Invalid hex string: %s", STR(source));
			return "";
		}
		if ((source[i * 2 + 1] >= '0') && (source[i * 2 + 1] <= '9')) {
			val |= (source[i * 2 + 1] - '0');
		} else if ((source[i * 2 + 1] >= 'a') && (source[i * 2 + 1] <= 'f')) {
			val |= (source[i * 2 + 1] - 'a' + 10);
		} else {
			FATAL("Invalid hex string: %s", STR(source));
			return "";
		}
		result += (char) val;
	}
	return result;
}
コード例 #8
0
 bool CCTextureASTC::initWithContentsOfFileAsync(const char* path)
 {
     int len = 0;
     std::string lowerCase(path);
     if (lowerCase.find(".ccz") != std::string::npos)
     {
         len = ZipUtils::ccInflateCCZFile(path, &m_data);
     }
     else if (lowerCase.find(".gz") != std::string::npos)
     {
         len = ZipUtils::ccInflateGZipFile(path, &m_data);
     }
     else
     {
         m_data = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&len));
     }
     
     if(len<0){
         deleteData();
         this->release();
         return false;
     }
     m_uName = 0;
     m_uWidth = m_uHeight = 0;
     if (!unpackData(m_data))
     {
         deleteData();
         this->release();
         return false;
     }
     /* Keep our GL texture name alive, even after we're destroyed. */
     setRetainName(true);
     
     return true;
 }
コード例 #9
0
ファイル: lua-udev.c プロジェクト: ijc25/lua-udev
static int list_entry2table(lua_State *L, UdevListEntry *list) {
    UdevListEntry *entry;
    lua_newtable(L);
    udev_list_entry_foreach(entry, list) {
        lua_pushstring(L, lowerCase(L, udev_list_entry_get_name(entry)));
        lua_pushstring(L, udev_list_entry_get_value(entry));
        lua_settable(L, -3);
    }
コード例 #10
0
ファイル: tokenizer.cpp プロジェクト: harkal/sylphis3d
string CTokenizerBase::getToken() {
    if(endOfStream)
        return "";
	if(lowerCaseTokens)
		token = lowerCase(token);

	return token;
}
コード例 #11
0
ファイル: caesar1.c プロジェクト: dudren/CS50
//changes alphabetical char from ascii to alpha number
char toAlpha(char asciiChar)
{
    int alphaNum = asciiChar;
    if(capital(asciiChar) == 1)
        alphaNum -= 65;
    if(lowerCase(asciiChar) == 1)
        alphaNum -= 97;
    return alphaNum;
}
コード例 #12
0
ファイル: caesar1.c プロジェクト: dudren/CS50
//changes alphabetical char from alpha to ascii number
char toAscii(char alphaChar)
{
    int asciiChar = alphaChar;
    if(capital(alphaChar) == 1)
        asciiChar += 65;
    if(lowerCase(alphaChar) == 1)
        asciiChar += 97;
    return asciiChar;
}
コード例 #13
0
ファイル: ByteArray.cpp プロジェクト: SylerWang/FunFashion
bool ByteArray::equalsIgnoreCase(const char* value)
{
	int len = (int)strlen(value);
	if (m_stringLength != len)
	{
		return false;
	}

	for (int i = 0; i < len; ++i)
	{
		if (lowerCase(m_data[i]) != lowerCase(value[i]))
		{
			return false;
		}
	}

	return true;
}
コード例 #14
0
bool InboundXMLCLIProtocol::ParseCommand(string &command) {
  //1. Replace the '\\' escape sequence
  replace(command, "\\\\", "_#slash#_");

  //2. Replace the '\ ' escape sequence
  replace(command, "\\ ", "_#space#_");

  //2. Replace the '\=' escape sequence
  replace(command, "\\=", "_#equal#_");

  //2. Replace the '\,' escape sequence
  replace(command, "\\,", "_#coma#_");

  //3. Append "cmd=" in front of the command
  command = "cmd=" + command;
  //INFO("command: `%s`", STR(command));

  //4. create the map
  map<string, string> rawMap = mapping(command, " ", "=", true);

  //5. Create the variant
  Variant message;
  message["command"] = rawMap["cmd"];
  rawMap.erase("cmd");

  string key;
  string value;
  vector<string> list;

  FOR_MAP(rawMap, string, string, i) {
    key = lowerCase(MAP_KEY(i));
    replace(key, "_#space#_", " ");
    replace(key, "_#slash#_", "\\");
    replace(key, "_#equal#_", "=");
    replace(key, "_#coma#_", ",");

    value = MAP_VAL(i);
    replace(value, "_#space#_", " ");
    replace(value, "_#slash#_", "\\");
    replace(value, "_#equal#_", "=");

    list.clear();
    split(value, ",", list);
    if (list.size() != 1) {
      for (uint32_t j = 0; j < list.size(); j++) {
        trim(list[j]);
        if (list[j] == "")
          continue;
        replace(list[j], "_#coma#_", ",");
        message["parameters"][key].PushToArray(list[j]);
      }
    } else {
      replace(value, "_#coma#_", ",");
      message["parameters"][key] = value;
    }
  }
コード例 #15
0
	bool getBool( std::string prompt )
	{
		do
		{
			std::string userAnswer = lowerCase(getString( prompt ));
			if ( userAnswer == "y" || userAnswer == "yes" ) return true;
			if ( userAnswer == "n" || userAnswer == "no" ) return false;
			std::cout << "Enter y, yes, n, or no." << std::endl;
		} while ( true );
	}
コード例 #16
0
ファイル: Options.cpp プロジェクト: aakoshh/StataDwPlugin
map<string,string> OptionParser::Parse(vector<string> words) {	
	// return a dictionary collecting the various parts of the commands according to the keys we got in the constructor
	map<string,string> options;	
	// parse words into dictionary: if the current word is not a keyword add it to the already parsed part, if it is, add a new entry	
	string currentKey;
	for( size_t i=0; i < words.size(); i++ ) {
		// if the current word is a keyword, use it from now
		bool isKeyword = this->keys.find(lowerCase(words[i])) != this->keys.end();
		if( isKeyword ) {
			currentKey = lowerCase(words[i]);
			// take note in the map that the option was there, so it is at least a flag
			options[currentKey] = ""; // it would have returned this anyway if looked up this way, so later we must check with find
		} else { // a value must be
			if( currentKey == "" ) // the words have to begin with a keyword 
				throw DwUseException("Cannot decide what option '" + words[i] + "' belongs to.");
			string opt = options[currentKey];
			// insert a space between parts, but until the next option it will be one string
			options[currentKey] = (opt == "" ? opt : opt + " ") + words[i];
		}
	}
	return options;
}
コード例 #17
0
ファイル: main.cpp プロジェクト: cobookman/HW-ECE2035
//fcn to get acknowledgement from serial peripheral
void waitForAck(void) {
    //get acknowlegement
    char buffer[BUFFSIZE];
    while(1) {
        serDevice.receiveData(buffer);
        lowerCase(buffer);
        if(strcmp(ACK, buffer) == 0) {
            break;
        }
        memset(&buffer[0],0,strlen(buffer));     
    }
    return;
}
コード例 #18
0
ファイル: ContentTypeManager.cpp プロジェクト: Gingar/port
	string ContentTypeManager::getMimeType(string fileExtension) {
		string mType = "";
        fileExtension = lowerCase(fileExtension);
		pthread_mutex_lock(&mutex);
		if (fileExtension != "" &&
				mimeDefaultTable.count(fileExtension) != 0) {

			mType = mimeDefaultTable[fileExtension];
		}
		pthread_mutex_unlock(&mutex);

		return mType;
	}
コード例 #19
0
ファイル: Indexer.cpp プロジェクト: patrickcarlson/STL
///
/// Parsing function for creation of Indexer object. Takes words from file to index
/// and strips them of punctuation, converts all chars to lower case, then compares
/// with strings in skip file. It will finally store those that apply to these 
/// guidelines, including their page number and line number.
///
void Indexer::parseFile()
{
	std::ifstream inFile;
	std::string inputLine;

	inFile.open(inFileName);
	
	if (!inFile.is_open())
	{
		std::cout << "No index file present with that name." << std::endl;
		system("PAUSE");
		exit(0);

	}

	while (!inFile.eof()) // First loop acquires a line from the text file.
	{
		std::getline(inFile, inputLine);

		std::istringstream stringParse(inputLine);

		incLineNmbr();
		while (!stringParse.eof())	// Inner loop breaks line up into strings.
		{
			std::string token;

			stringParse >> token;
			if (token == "")		// Check for empty strings.
				continue;

			if (token == "<newpage>")
			{
				incPageNmbr();
				lineNmbr = 0;

				break;
			}
			punctStrip(token);		// Call function to remove punctuation

			lowerCase(token);		// Convert to lower case.

			if (!wordsToSkip.skipWordcheck(token))	// Check for string in skipWords.
				continue;

			addToIndex(token);
		}
		
	}

	
}
コード例 #20
0
ファイル: Date.cpp プロジェクト: SEJeff/task
int Date::dayOfWeek (const std::string& input)
{
  std::string in = lowerCase (input);

  if (in == STRING_DATE_SUNDAY_LONG    || in == STRING_DATE_SUNDAY_SHORT)    return 0;
  if (in == STRING_DATE_MONDAY_LONG    || in == STRING_DATE_MONDAY_SHORT)    return 1;
  if (in == STRING_DATE_TUESDAY_LONG   || in == STRING_DATE_TUESDAY_SHORT)   return 2;
  if (in == STRING_DATE_WEDNESDAY_LONG || in == STRING_DATE_WEDNESDAY_SHORT) return 3;
  if (in == STRING_DATE_THURSDAY_LONG  || in == STRING_DATE_THURSDAY_SHORT)  return 4;
  if (in == STRING_DATE_FRIDAY_LONG    || in == STRING_DATE_FRIDAY_SHORT)    return 5;
  if (in == STRING_DATE_SATURDAY_LONG  || in == STRING_DATE_SATURDAY_SHORT)  return 6;

  return -1;
}
コード例 #21
0
bool GreekLowerCaseFilter::incrementToken() {
    if (input->incrementToken()) {
        wchar_t* chArray = termAtt->termBufferArray();
        int32_t chLen = termAtt->termLength();

        for (int32_t i = 0; i < chLen; ++i) {
            chArray[i] = lowerCase(chArray[i]);
        }

        return true;
    } else {
        return false;
    }
}
コード例 #22
0
Widget::HorizontalAlignment Style::strToHAlign(const std::string& halign) {
    std::string ha = lowerCase(halign);

    if(ha == "center") return Widget::HA_CENTER;

    else if(ha == "left") return Widget::HA_LEFT;

    else if(ha == "right") return Widget::HA_RIGHT;

    else {
        warn() << "Unkown HAlign name [" << halign << "]; using HA_CENTER." << std::endl;

        return Widget::HA_CENTER;
    }
}
コード例 #23
0
Widget::VerticalAlignment Style::strToVAlign(const std::string& valign) {
    std::string va = lowerCase(valign);

    if(va == "center") return Widget::VA_CENTER;

    else if(va == "top") return Widget::VA_TOP;

    else if(va == "bottom") return Widget::VA_BOTTOM;

    else {
        warn() << "Unkown VAlign name [" << valign << "]; using VA_CENTER." << std::endl;

        return Widget::VA_CENTER;
    }
}
コード例 #24
0
bool Style::strToFill(const std::string& fill) {
    std::string cm = lowerCase(fill);

    if(cm == "true") return true;

    else if(cm == "false") return false;

    else {
        warn()
            << "Unkown Fill name [" << fill
            << "]; using false." << std::endl
        ;

        return false;
    }
}
コード例 #25
0
Widget::CoordinateMode Style::strToCoordMode(const std::string& coordmode) {
    std::string cm = lowerCase(coordmode);

    if(cm == "absolute") return Widget::CM_ABSOLUTE;

    else if(cm == "relative") return Widget::CM_RELATIVE;

    else {
        warn()
            << "Unkown CoordMode name [" << coordmode
            << "]; using CM_ABSOLUTE." << std::endl
        ;

        return Widget::CM_ABSOLUTE;
    }
}
コード例 #26
0
ファイル: bibleworks.cpp プロジェクト: alerque/bibledit
bool bibleworks_is_running ()
// Returns whether BibleWorks runs.
// The reason this was introduced is so that older and future versions of BibleWorks are likely to be recognized.
{
  bool running = false;
  vector <ustring> processes = list_processes ();
  for (unsigned int i = 0; i < processes.size(); i++) {
    ustring process = lowerCase (processes[i]);
    size_t pos = process.find ("0.exe");
    if (pos != string::npos) {
      process.erase (0, pos - 6);
      pos = process.find ("bw");
      running = (pos != string::npos);
    }
  }
  return running;
}
コード例 #27
0
bool InboundMJPGHTTPStreamProtocol::SignalInputData(IOBuffer &buffer) {
	//1. Is the stream name acquired?
	if (_streamNameAcquired) {
		buffer.IgnoreAll();
		return true;
	}

	if (!AcquireStreamName(buffer)) {
		FATAL("Unable to get the stream name");
		return false;
	}

	if (!_streamNameAcquired) {
		return true;
	}

	//7. Search for the stream called streamName and pick the first one
	map<uint32_t, BaseStream *> inStreams =
			GetApplication()->GetStreamsManager()->FindByTypeByName(
			ST_IN_CAM_MJPG, _streamName, false, true);
	if (inStreams.size() == 0) {
		if (lowerCase(_streamName) == "crossdomain.xml") {
			return SendCrossDomain();
		} else {
			FATAL("Stream %s not found", STR(_streamName));
			return Send404NotFound();
		}
	}
	BaseInStream *pInStream = (BaseInStream *) MAP_VAL(inStreams.begin());

	//8. Create our raw outbound stream
	_pOutStream = new OutNetMJPGHTTPStream(this,
			GetApplication()->GetStreamsManager(), _streamName);

	//9. Link it to the in stream
	if (!pInStream->Link(_pOutStream)) {
		FATAL("Unable to link to the in stream");
		return false;
	}

	//10. All done. Ignore all the traffic
	buffer.IgnoreAll();

	//11. Done
	return true;
}
コード例 #28
0
void Changecase::process()
{
    emit startMacro(i18n("Change case"));

    if (m_sentenceCaseRadio->isChecked())
        sentenceCase();
    else if (m_lowerCaseRadio->isChecked())
        lowerCase();
    else if (m_upperCaseRadio->isChecked())
        upperCase();
    else if (m_initialCapsRadio->isChecked())
        initialCaps();
    else if (m_toggleCaseRadio->isChecked())
        toggleCase();

    emit stopMacro();
}
コード例 #29
0
ファイル: BSA.cpp プロジェクト: Thoronador/morrowtools
uint32_t BSA::getIndexOfFolder(std::string folderName) const
{
  if (!hasAllStructureData())
  {
    std::cout << "BSA::getIndexOfFolder: Error: not all structure data is "
              << "present to properly fulfill the requested operation!\n";
    return cIndexNotFound;
  }

  if (folderName.empty()) return cIndexNotFound;
  //transform to lower case
  folderName = lowerCase(folderName);
  uint32_t i;
  for (i=0; i<m_FolderBlocks.size(); ++i)
  {
    if (m_FolderBlocks.at(i).folderName==folderName) return i;
  }//for
  return cIndexNotFound;
}
コード例 #30
0
ファイル: utils.c プロジェクト: jkermes/Socket-Training
int countConsonants(char *buffer)
{    
    int i = 0, j, count = 0;
    int consonants[21] = {'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'};
    
    buffer = lowerCase(buffer);
    
    do {        
        for (j = 0; j < sizeof(consonants) / sizeof(int); j++) {
            if (buffer[i] == (int) consonants[j]) {
                count++;                
            }
        }
        
        i++;
    } while ('\0' != buffer[i]);
    
    return count;
}