コード例 #1
0
void CPatternsFileProcessor::readLine()
{
	check_logic( file.good() );

	++lineNumber;
	getline( file, line, '\n' );

	// support windows EOL style "\r\n"
	if( !line.empty() && line.back() == '\r' ) {
		line.erase( prev( line.end() ) ); // line.pop_back();
	}

	const string::size_type invalidByteOffset = IsValidUtf8( line );
	if( invalidByteOffset == string::npos ) {
		// not so effective...
		ReplaceTabsWithSpacesInSignleLine( line );

		const string::size_type invalidCharOffset = IsValidText( line );
		if( invalidCharOffset != string::npos ) {
			errorProcessor.AddError( CError(
				CLineSegment( invalidCharOffset ),
				CSharedFileLine( line, lineNumber ),
				"the file is not a text file", ES_CriticalError ) );
			line.clear();
		}
	} else {
		errorProcessor.AddError( CError(
			CLineSegment( invalidByteOffset ),
			CSharedFileLine( line, lineNumber ),
			"the file is not valid UTF-8 file", ES_CriticalError ) );
		line.clear();
	}
}
コード例 #2
0
// The line is a continuation of a previous one if:
// 1. it starts with space or horizontal tab;
// 2. it contains at least one token.
void CPatternsFileProcessor::ReadPattern( CTokens& patternTokens )
{
	patternTokens.clear();

	check_logic( file.is_open() );
	check_logic( !tokenizer.empty() );
	check_logic( !errorProcessor.HasCriticalErrors() );

	if( lineStartsWithSpace() ) {
		errorProcessor.AddError( CError(
			CLineSegment( 0, tokenizer.front()->Offset + 1 ),
			CSharedFileLine( line, lineNumber ),
			"a pattern definition is required to be"
			" written from the first character of the line" ) );
	}
	line.clear();

	// read rest lines of pattern
	while( file.good() ) {
		readLine();
		if( !lineStartsWithSpace() ) {
			break;
		}
		if( !tokenizeLine() ) {
			line.clear();
			break;
		}
	}

	patternTokens = move( tokenizer );
	skipEmptyLines();
}
コード例 #3
0
ファイル: HandleShapes.cpp プロジェクト: dlxgit/OOP
void AddLine(const std::vector<std::string> & inputParts, std::vector<std::shared_ptr<CShape>> & figures, std::vector<std::shared_ptr<sf::Shape>> & shapes)
{
	CPoint p1 = CPoint(std::stod(inputParts[1]), std::stod(inputParts[2]));
	CPoint p2 = CPoint(std::stod(inputParts[3]), std::stod(inputParts[4]));
	std::string outlineColor = inputParts[5];
	CLineSegment line = CLineSegment(p1, p2, outlineColor);

	sf::RectangleShape drawingLine(sf::Vector2f((float)line.GetPerimeter(), (float)2));
	sf::RectangleShape(sf::Vector2f((float)line.GetPerimeter(), 3.f));

	p2.GetPosition().first < p1.GetPosition().first ? drawingLine.setPosition(float(p2.GetPosition().first), float(p2.GetPosition().second)) : drawingLine.setPosition(float(p1.GetPosition().first), float(p1.GetPosition().second));
	drawingLine.setRotation(float(std::atan((p2.GetPosition().second - p1.GetPosition().second) / (p2.GetPosition().first - p1.GetPosition().first)) * 180 / boost::math::constants::pi<double>()));

	drawingLine.setFillColor(ConvertHexToRgb(inputParts[5]));
	drawingLine.setOutlineThickness(3.f);
	figures.push_back(std::make_shared<CLineSegment>(line));
	shapes.push_back(std::make_shared<sf::RectangleShape>(drawingLine));

}
コード例 #4
0
ファイル: CTriangle.cpp プロジェクト: SuperStealth/LabWork4
CLineSegment CTriangle::GetSide3() const
{
	return CLineSegment(m_point2, m_point3);
}
コード例 #5
0
ファイル: CTriangle.cpp プロジェクト: SuperStealth/LabWork4
CLineSegment CTriangle::GetSide1() const
{
	return CLineSegment(m_point1, m_point2);
}