Esempio n. 1
0
// Public Methods
Vector2d GridEmitter::startPos( int p )
{
    int i = p / grid(1);
    int j = p % grid(1);

    return Vector2d( delimiter(0, 0) + i * dx,
                     delimiter(1, 0) + j * dy );
}
Esempio n. 2
0
  std::basic_string<C>
  perl_s (std::basic_string<C> const& src, std::basic_string<C> const& e)
  {
    typedef std::basic_string<C> string;
    typedef typename string::size_type size;

    if (e.empty ())
      return src;

    C delimiter (e[0]);

    size first = e.find (delimiter);
    size middle = e.find (delimiter, first + 1);
    size last = e.find (delimiter, middle + 1);

    string pattern (e, first + 1, middle - first - 1);
    string format (e, middle + 1, last - middle - 1);

    //std::cout << pattern << "  " << format << std::endl;

    boost::basic_regex<C> expr (pattern);

    return regex_merge (
      src,
      expr,
      format,
      boost::match_default | boost::format_all );
  }
Esempio n. 3
0
/** Parses the sets of a file **/
std::vector<std::set<unsigned int>*>* ParseSets(std::ifstream& file) {
	std::list<std::set<unsigned int>*> * auxSets = new std::list<std::set<unsigned int>*>();
	std::string line;
	std::string delimiter(" ");
	while(std::getline(file,line)) {
		std::set<unsigned int>* set = new std::set<unsigned int>();
		size_t nextToken = 0;
		std::istringstream stream(line);
		unsigned int node;
		while( stream >> node ) {
			set->insert(node);
		}

		if(set->size()>2) {
			auxSets->push_back(set);
		}
	}

	std::vector<std::set<unsigned int>*> * returnSet = new std::vector<std::set<unsigned int>*>();
	std::list<std::set<unsigned int>*>::iterator it;
	unsigned int i = 0;
	for(it = auxSets->begin();it!=auxSets->end();++it,++i) {
		returnSet->push_back(*it);
	}
	return returnSet;
}
Esempio n. 4
0
std::string ZLDir::itemPath(const std::string &itemName) const {
	if (itemName == "..") {
		return parentPath();
	} else {
		return isRoot() ? myPath + itemName : myPath + delimiter() + itemName;
	}
}
Esempio n. 5
0
void MainWindow::printResult()
{
    int s1[MAX_LENGHT];
    int s0[MAX_LENGHT];

    QString delimiter(",");
    QStringList sets1;
    QStringList sets0;

    sets1 = this->text1.split(delimiter);
    sets0 = this->text0.split(delimiter);

    int i;
    for(i = 0; i<sets1.length(); i++)
    {
        QString str;
        str = sets1[i];
        s1[i] = str.toInt();

    }
    s1[i] = END;
    for(i = 0; i<sets0.length(); i++)
    {
        QString str;
        str = sets0[i];
        s0[i] = str.toInt();

    }
    s0[i] = END;

    setResultText(quine_start(s1,s0));
}
Esempio n. 6
0
void tex::math_left_right ()
	{
	ptr	p;
	int	t;
	mcell	garbage;

	t = cur_chr;
	if (t == RIGHT_NOAD && cur_group != MATH_LEFT_GROUP) {
		if (cur_group == MATH_SHIFT_GROUP) {
			scan_delimiter((ptr)&garbage, FALSE);
			print_err("Extra ");
			print_esc("right");
			help_xtra_right();
			error();
		} else {
			off_save();
		}
	} else {
		p = new_noad();
		type(p) = t;
		scan_delimiter(delimiter(p), FALSE);
		if (t == LEFT_NOAD) {
			push_math(MATH_LEFT_GROUP);
			tail = link(head) = p;
		} else {
			p = fin_mlist(p);
			unsave();
			tail_append(new_noad());
			type(tail) = INNER_NOAD;
			math_type(nucleus(tail)) = SUB_MLIST;
			math_link(nucleus(tail)) = p;
		}
	}
}
Esempio n. 7
0
void XMLBase::setGroup(const std::string& groupName)
{
    _groupNames.clear();

    size_t start   = 0;
    size_t end     = 0;
    std::string delimiter("/");

    // Quick return when called with empty group name
    if (groupName.empty() || (groupName == "/"))
        return;

    // Don't care for a preceding delimiter
    if (groupName.at(0) == delimiter.at(0)) ++start;

    while (end != std::string::npos)
    {
        end = groupName.find(delimiter, start);

        // If at end, use length = maxLength.  Else use length = end - start.
        _groupNames.push_back(groupName.substr(start, (end == std::string::npos) ? std::string::npos : end - start));

        // If at end, use start = maxSize.  Else use start = end + delimiter.
        start = ((end > (std::string::npos - delimiter.size())) ? std::string::npos : end + delimiter.size());
    }
}
Esempio n. 8
0
bool Highlighter::matchMultiline(const QString& text, const ::HighlightingRule& rule)
{
	QRegExp delimiter(rule.pattern);
	int start = 0;
	int add = 0;
	int end = 0;
	int length = 0;
	if (previousBlockState() != rule.index)
	{
		start = delimiter.indexIn(text);
		add = delimiter.matchedLength();
	}

	while (start >= 0)
	{
		end = delimiter.indexIn(text, start + add);
		if (end >= add)
		{
			length = end - start + add + delimiter.matchedLength();
			setCurrentBlockState(0);
		}
		else
		{
			setCurrentBlockState(rule.index);
			length = text.length() - start + add;
		}
		QTextCharFormat fmt;
		if (m_Formats.contains(rule.t))
			fmt = m_Formats[rule.t];
		setFormat(start, length, fmt);
		start = delimiter.indexIn(text, start + length);
	}
	return currentBlockState() == rule.index;
}
Esempio n. 9
0
void ZLUnixFSDir::collectFiles(std::vector<std::string> &names, bool includeSymlinks) {
	DIR *dir = opendir(path().c_str());
	if (dir != 0) {
		const std::string namePrefix = path() + delimiter();
		const dirent *file;
		struct stat fileInfo;
		std::string shortName;
		while ((file = readdir(dir)) != 0) {
			shortName = file->d_name;
			if ((shortName == ".") || (shortName == "..")) {
				continue;
			}
			const std::string path = namePrefix + shortName;
			if (includeSymlinks) {
				stat(path.c_str(), &fileInfo);
			} else {
				lstat(path.c_str(), &fileInfo);
			}
			if (S_ISREG(fileInfo.st_mode)) {
				names.push_back(shortName);
			}
		}
		closedir(dir);
	}
}
Esempio n. 10
0
bool CSSParserToken::operator==(const CSSParserToken& other) const
{
    if (m_type != other.m_type)
        return false;
    switch (m_type) {
    case DelimiterToken:
        return delimiter() == other.delimiter();
    case HashToken:
        if (m_hashTokenType != other.m_hashTokenType)
            return false;
        FALLTHROUGH;
    case IdentToken:
    case FunctionToken:
    case StringToken:
    case UrlToken:
        return valueDataCharRawEqual(other);
    case DimensionToken:
        if (!valueDataCharRawEqual(other))
            return false;
        FALLTHROUGH;
    case NumberToken:
    case PercentageToken:
        return m_numericSign == other.m_numericSign && m_numericValue == other.m_numericValue && m_numericValueType == other.m_numericValueType;
    case UnicodeRangeToken:
        return m_unicodeRange.start == other.m_unicodeRange.start && m_unicodeRange.end == other.m_unicodeRange.end;
    default:
        return true;
    }
}
Esempio n. 11
0
////////////////////////////////////////
// Particle Property Generators (private)
Vector3d GridOnceEmitter::startPos( int p )
{
    // What variables are used in this function?

    /*
     * This function directly calculates the starting position from the
     * particle number; this comes in handy when resetting particles, if
     * they leave the cube, to the position they started;
     */
    int i = p / (grid(1) * grid(2));
    int j = ( p % (grid(1) * grid(2)) ) / grid(2) ;
    int k = p % grid(2);

    return Vector3d( delimiter(0, 0) + i * dx,
                     delimiter(1, 0) + j * dy,
                     delimiter(2, 0) + k * dz );
}
Esempio n. 12
0
char* ClassBuffer::FindClassDecl (TextBuffer* tb, int& beg) {
    Regexp classKeyWord("^class[ $]");
    Regexp delimiter("[:{;]");
    char* className = nil;
    int obeg = beg;

    for (;;) {
        beg = tb->ForwardSearch(&classKeyWord, beg);

        if (beg < 0) {
            break;
        }
        int tmp = beg;
        int delim = tb->ForwardSearch(&delimiter, tmp);
            
        if (delim >= 0 && *tb->Text(delim-1) != ';') {
            className = Identifier(tb, beg);
            break;
        }
    }
    if (className && (strcmp(className, "VTK_EXPORT")==0||strcmp(className, "ACE_Export")==0)) {
      // retry this time skipping the extra token
      Regexp classKeyWord(strcmp(className, "VTK_EXPORT")==0 ? 
			  "^class VTK_EXPORT[ $]" : "^class ACE_Export[ $]");
      Regexp delimiter("[:{;]");
      beg = obeg;

      for (;;) {
        beg = tb->ForwardSearch(&classKeyWord, beg);

        if (beg < 0) {
            break;
        }
        int tmp = beg;
        int delim = tb->ForwardSearch(&delimiter, tmp);
            
        if (delim >= 0 && *tb->Text(delim-1) != ';') {
            className = Identifier(tb, beg);
            break;
        }
      }
    }
    return className;
}
Esempio n. 13
0
void Plateau::affiche() {
    
    delimiter(_dim);
    for (int i = 0; i < _dim; i++) {
        for (int j = 0; j < _dim; j++) {
            cout << "|";
            
            if (_gameboard[i][j].free()) {
                cout << " . ";
            }else if(_gameboard[i][j].broken()) {
                cout << " X ";
            }else{
                cout << ">O<";
            }
        }
        cout << "| " << i + 1 << endl;
        delimiter(_dim);
    }
}
Esempio n. 14
0
void PointSets::exportToStreamEachCurveSeparately(Q3TextStream& str, CoordSettings coord,
  GridMeshSettings grid, ExportSettings xport, int xPrecision, int yPrecision)
{
  // list of x values in ascending order
  QList<double> xUsed = ascendingXValuesList(coord, grid, xport, xPrecision);

  for (PointSetList::iterator itrG = curveList.begin(); itrG != curveList.end(); ++itrG)
    if ((*itrG).getExport())
    {
      if (xport.header != HeaderNone)
      {
        // header
        str << exportHeaderPrefix(coord, xport);
        str << delimiter(xport.delimiters);
        str << (*itrG).exportCurveHeader(xport);
        str << "\n";
      }

      if (xport.pointsSelection == XYFromAllCurves)
        str << (*itrG).exportCurveAll(xport, xPrecision, yPrecision);
      else
      {
        // loop through x values with one per line
        const bool useInterpolation = true;
        QString xNew;
        QList<double>::iterator itrX;
        for (itrX = xUsed.begin(); itrX != xUsed.end(); ++itrX)
        {
          str << xNew.setNum(*itrX, 'g', xPrecision);
          str << delimiter(xport.delimiters);
          str << (*itrG).exportCurvePoint(*itrX, coord, useInterpolation, yPrecision);
          str << "\n";
        }
      }

      if (xport.header == HeaderGnuplot)
      {
        // gnuplot expects two blank records between successive data blocks
        str << "\n\n";
      }
    }
}
Esempio n. 15
0
void PointSets::exportToStreamAllCurvesTogether(Q3TextStream& str, CoordSettings coord,
  GridMeshSettings grid, ExportSettings xport, int xPrecision, int yPrecision)
{
  // list of x values in ascending order
  QList<double> xUsed = ascendingXValuesList(coord, grid, xport, xPrecision);

  if (xport.header != HeaderNone)
  {
    // header
    str << exportHeaderPrefix(coord, xport);
    for (PointSetList::iterator itrG = curveList.begin(); itrG != curveList.end(); ++itrG)
      if ((*itrG).getExport())
      {
        str << delimiter(xport.delimiters);
        str << (*itrG).exportCurveHeader(xport);
      }
    str << "\n";
  }

  // if only allowing raw data, then forgo interpolation
  bool useInterpolation = (xport.pointsSelection != XYFromAllCurves);

  // loop through x values with one per line
  QString xNew;
  QList<double>::iterator itrX;
  for (itrX = xUsed.begin(); itrX != xUsed.end(); ++itrX)
  {
    xNew.setNum(*itrX, 'g', xPrecision);

    str << xNew;
    for (PointSetList::iterator itrG = curveList.begin(); itrG != curveList.end(); ++itrG)
      if ((*itrG).getExport())
      {
        str << delimiter(xport.delimiters);
        str << (*itrG).exportCurvePoint(*itrX, coord, useInterpolation, yPrecision);
      }

    str << "\n";
  }
}
Esempio n. 16
0
void ExtendedTableData::getRows(uint64_t startRow, uint64_t rows, std::vector<DataChunk>& chunks) const {
    DataChunk delimiter((char*)"\t",1);
    DataChunk eol((char*)"\n",1);
    for (uint64_t row = startRow; row < startRow + rows; row++) {
        for (uint32_t col = 0; col < getColCount(); col++) {
            chunks.push_back(getColumn(row,col));
            if (col < getColCount() - 1) {
                chunks.push_back(delimiter);
            }
        }
        chunks.push_back(eol);
    }
}
Istream& Istream::readBegin(const char* funcName)
{
    token delimiter(*this);
    if (delimiter != token::BEGIN_LIST)
    {
        setBad();
        FatalIOErrorIn("Istream::readBegin(const char*)", *this)
            << "Expected a " << '\'' << token:: BEGIN_LIST << '\''
            << " while reading " << funcName
            << ", found " << delimiter.info()
            << exit(FatalIOError);
    }

    return *this;
}
Esempio n. 18
0
Foam::Istream& Foam::Istream::readEnd(const char* funcName)
{
    token delimiter(*this);
    if (delimiter != token::END_LIST)
    {
        setBad();
        FatalIOErrorIn("Istream::readEnd(const char*)", *this)
            << "Expected a '" << token::END_LIST
            << "' while reading " << funcName
            << ", found " << delimiter.info()
            << exit(FatalIOError);
    }

    return *this;
}
Esempio n. 19
0
void SettingsKey::from_string(const char* key, char separator)
{
    tokens_.clear();
    key_ = string(key);
    sep_ = separator;
    string s = key_;
    string delimiter(1, sep_);
    size_t pos = 0;
    string token;
    while ((pos = s.find(delimiter)) != string::npos)
    {
        token = s.substr(0, pos);
        tokens_.push_back(token);
        s.erase(0, pos + delimiter.length());
    }
    tokens_.push_back(s);
}
Esempio n. 20
0
static String parseClause(const char* keyword, size_t keywordLength, FILE* file, const char* line, char* buffer, size_t bufferSize)
{
    const char* keywordPos = strstr(line, keyword);
    if (!keywordPos)
        FAIL_WITH_ERROR(SYNTAX_ERROR, ("Expecting '", keyword, "' clause:\n", line, "\n"));
    if (keywordPos != line)
        FAIL_WITH_ERROR(SYNTAX_ERROR, ("Cannot have any characters before '", keyword, "':\n", line, "\n"));
    if (line[keywordLength] != ' ')
        FAIL_WITH_ERROR(SYNTAX_ERROR, ("'", keyword, "' must be followed by a ' ':\n", line, "\n"));

    const char* delimiterStart = &line[keywordLength + 1];
    const char* delimiterEnd = strstr(delimiterStart, "{");
    if (!delimiterEnd)
        FAIL_WITH_ERROR(SYNTAX_ERROR, ("Missing { after '", keyword, "' clause start delimiter:\n", line, "\n"));
    
    size_t delimiterLength = delimiterEnd - delimiterStart;
    String delimiter(delimiterStart, delimiterLength);

    if (hasDisallowedCharacters(delimiterStart, delimiterLength))
        FAIL_WITH_ERROR(SYNTAX_ERROR, ("Delimiter '", delimiter, "' cannot have '{', '}', or whitespace:\n", line, "\n"));
    
    String terminatorString;
    terminatorString.append("}");
    terminatorString.append(delimiter);

    const char* terminator = terminatorString.ascii().data();
    line = delimiterEnd; // Start from the {.

    StringBuilder builder;
    do {
        const char* p = strstr(line, terminator);
        if (p) {
            if (p[strlen(terminator)] != '\n')
                FAIL_WITH_ERROR(SYNTAX_ERROR, ("Unexpected characters after '", keyword, "' clause end delimiter '", delimiter, "':\n", line, "\n"));

            builder.append(line, p - line + 1);
            return builder.toString();
        }
        builder.append(line);

    } while ((line = fgets(buffer, bufferSize, file)));

    FAIL_WITH_ERROR(SYNTAX_ERROR, ("'", keyword, "' clause end delimiter '", delimiter, "' not found:\n", builder.toString(), "\n", "Are you missing a '}' before the delimiter?\n"));
}
Esempio n. 21
0
void Vec3Type::setValue(std::string value)
{
    std::string delimiter(",");

    std::istringstream ss(value);
    std::string token;
    int index = 0;

    while(std::getline(ss, token, ',')) 
    {
            std::stringstream val(token);
            val >> _value[index];
            index++;
            
            // stop going outside bounds
            if( index > 2 )
                break;        
    }
}
char Istream::readEndList(const char* funcName)
{
    token delimiter(*this);

    if (delimiter != token::END_LIST && delimiter != token::END_BLOCK)
    {
        setBad();
        FatalIOErrorIn("Istream::readEndList(const char*)", *this)
            << "Expected a " << '\'' << token::END_LIST << '\''
            << " or a " << '\'' << token::END_BLOCK << '\''
            << " while reading " << funcName
            << ", found " << delimiter.info()
            << exit(FatalIOError);

        return '\0';
    }

    return delimiter.pToken();
}
Esempio n. 23
0
char Foam::Istream::readBeginList(const char* funcName)
{
    token delimiter(*this);

    if (delimiter != token::BEGIN_LIST && delimiter != token::BEGIN_BLOCK)
    {
        setBad();
        FatalIOErrorIn("Istream::readBeginList(const char*)", *this)
            << "Expected a '" << token::BEGIN_LIST
            << "' or a '" << token::BEGIN_BLOCK
            << "' while reading " << funcName
            << ", found " << delimiter.info()
            << exit(FatalIOError);

        return '\0';
    }

    return delimiter.pToken();
}
// -----------------------------------------------------------------------------
// UpnpAVCPEngine::ParsePathToElementsL
// -----------------------------------------------------------------------------
//   
void ParsePathToElementsL(TPtr8 aPath, RPointerArray<TPtrC8>& aArray ) 
	{
	TChar delimiter('/');
	RemoveSlashes(aPath);

	TPtrC8 ptr(aPath);
    TInt i = 0;

	while(KErrNotFound != ptr.Locate(delimiter))
	    {	
	    aArray.Append( new (ELeave)TPtrC8() );
		aArray[i]->Set(ptr.Left((ptr.Locate(delimiter))));
    	ptr.Set(ptr.Right(ptr.Length() - (ptr.Locate(delimiter) + 1)) ); 
	    i++;
	    }
	    
	aArray.Append( new (ELeave) TPtrC8() );
   	aArray[i]->Set(ptr);    		
	}
Esempio n. 25
0
char* ClassBuffer::FindClassDecl (TextBuffer* tb, int& beg) {
    Regexp classKeyWord("^class[ $]");
    Regexp delimiter("[:{;]");
    char* className = nil;

    for (;;) {
        beg = tb->ForwardSearch(&classKeyWord, beg);

        if (beg < 0) {
            break;
        }
        int tmp = beg;
        int delim = tb->ForwardSearch(&delimiter, tmp);
            
        if (delim >= 0 && *tb->Text(delim-1) != ';') {
            className = Identifier(tb, beg);
            break;
        }
    }
    return className;
}
Esempio n. 26
0
    void write_samples_to_csv(std::string const & file_name) const
    {
        std::string delimiter(",");
        std::ofstream out_file;
        out_file.open(file_name,std::ios::trunc);
        if( out_file.is_open() )
        {
            out_file << std::scientific;
            out_file << std::setprecision(10);
            for(size_t i=0;i<m_num_samples;++i)
            {
                out_file << m_weights(i) << delimiter;
                for(size_t j=0;j<size_t(m_num_dims-1);++j)
                {
                    out_file << m_chain(i,j) << delimiter;
                }
                out_file << m_chain(i,size_t(m_num_dims-1)) <<std::endl;
            }
        }

        out_file.close();
    }
Esempio n. 27
0
//*****************************************************************************
// BuckeyeSMPlugin::getSensorModelNameFromSensorModelState
//*****************************************************************************
TSMWarning *BuckeyeSMPlugin::getSensorModelNameFromSensorModelState(
                                  const std::string& sensor_model_state,
                                  std::string& sensor_model_name) const throw (TSMError)
{
   TSMWarning *tsmWarn = NULL;
   std::string myname("BuckeyeSMPlugin::getSensorModelNameFromSensorModelState");

   std::string delimiter (1, ':');
   std::vector<std::string> tokens;
//       std::cout << "1***********sensor_model_state =" << sensor_model_state << std::endl;
   BuckeyeSMPlugin::tokenize(sensor_model_state, tokens, delimiter);

   if (tokens[0].find(PLUGIN_NAME) == std::string::npos) 
   {
      TSMError tsmError(TSMError::INVALID_SENSOR_MODEL_STATE, "Invalid sensor model state.", myname);
      throw tsmError;
   }

   sensor_model_name = tokens[0];

   return tsmWarn;
}
Esempio n. 28
0
/*! 
 * Generate the display label
 * \a contact to read the data from .
 * \a detailList contains the details to be read from the contact
 * \return synthesised display label 
 */
QString CntDisplayLabel::generateDisplayLabel( const QContact &contact, const QList<QList<QPair<QLatin1String, QLatin1String> > > detailList) const
{
    // Default to empty display label. It is up to the client to create a
    // localised presentation of a contact without a name.
    QString displayLabel("");
    
    //loop through the details and create display label
    for(int i = 0; i < detailList.count() && displayLabel.isEmpty(); i++ )
    {
        QList<QPair<QLatin1String, QLatin1String> > detailPairList = detailList.at(i);
        QContactDetail contactDetail;
        
        for(int j = 0; j < detailPairList.count(); j++)
        {
            contactDetail = contact.detail(detailPairList.at(j).first);
                    
            if(displayLabel.isEmpty()){ //read the value and set it as display label
                displayLabel =  contactDetail.value(detailPairList.at(j).second);
            }
            else{ //read the value and append it to the display label
                QString label = contactDetail.value(detailPairList.at(j).second);
                
                if(!label.isEmpty())
                {
#ifdef SYMBIAN_BACKEND_USE_SQLITE
                    // Inlcude a comma if needed in the display label
                    if (m_nameOrder == CntOrderLastCommaFirst)
                        displayLabel.append(comma());
#endif
                    displayLabel.append(delimiter());                        
                    displayLabel.append(label);
                }  
            }
        }
    }

    return displayLabel;
}
// Saves playlist of the day to csv file.
void RadioStation::savePlaylistOfTheDayToFile() {
	std::string filename = "playlistOfTheDay.csv";

	remove(filename.c_str());

	fstream file(filename); 

	file.open(filename, ios::out);

	file << "id,title,author,album,genre,year,likes,dislikes,available\n";

	for(vector<MusicTrack>::iterator vPtr = playlistOfTheDay.begin(); 
		vPtr != playlistOfTheDay.end(); vPtr++) {

			file << vPtr->getID() << delimiter() << vPtr->getTitle() << delimiter() << vPtr->getAlbum() 
				<< delimiter() << vPtr->getMusicGenre() << delimiter() << vPtr->getYear() 
				<< delimiter() << vPtr->getLikes() << delimiter() << vPtr->getDislikes()
				<< delimiter() << vPtr->getAvailable() << std::endl;

	}

}
Esempio n. 30
0
char* ClassBuffer::ParentName (TextBuffer* tb, int& beg) {
    Regexp delimiter("{");
    int delim = tb->ForwardSearch(&delimiter, beg);
    if (delim < 0) {
	return nil;
    }

    for (;;) {
        char* string = Identifier(tb, beg);

        if (string == nil || beg >= delim) {
            delete string;
            beg = delim;
            return nil;

        } else if (KeyWord(string)) {
            delete string;
            string = nil;

        } else {
            return string;
        }
    }
}