Hallo Leute,
Bin gerade dabei so ne Art CSS-Parser zu entwickeln und zwar vor allem deswegen weil ich mir mal die boost::regex library anschauen will. Hab auch grad keinen Fehler was das angeht.... wollte aber wissen was man den noch so in einen solchen Parser einbauen könnte. Aber nun zum Fehler: Ich hab ne Klasse "StyleBlock":
sowie dessen Implementierung:
desweiteren die main-Funktion:
Leider gibt er mir bei der Ausführung diesen Fehler aus:
Fehler: Abfrage des Elementes »FromString« in »sb«, das vom Nicht-Klassentyp »StyleBlock()« ist|
||=== Build finished: 1 errors, 0 warnings ===|
Kann mir da vll jemand helfen?
Bin gerade dabei so ne Art CSS-Parser zu entwickeln und zwar vor allem deswegen weil ich mir mal die boost::regex library anschauen will. Hab auch grad keinen Fehler was das angeht.... wollte aber wissen was man den noch so in einen solchen Parser einbauen könnte. Aber nun zum Fehler: Ich hab ne Klasse "StyleBlock":
C++:
#include <boost/regex.hpp>
#include <string>
#include <iostream>
class StyleBlock
{
public:
/** Default constructor */
StyleBlock();
/** Default destructor */
virtual ~StyleBlock();
/** Copy constructor
* \param other Object to copy from
*/
StyleBlock(const StyleBlock& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
StyleBlock& operator=(const StyleBlock& other);
void FromString(const std::string content);
protected:
private:
};
sowie dessen Implementierung:
C++:
#include "../include/styleblock.h"
StyleBlock::StyleBlock()
{
//ctor
}
StyleBlock::~StyleBlock()
{
//dtor
}
StyleBlock::StyleBlock(const StyleBlock& other)
{
//copy ctor
}
StyleBlock& StyleBlock::operator=(const StyleBlock& rhs)
{
if (this == &rhs) return *this; // handle self assignment
//assignment operator
return *this;
}
void StyleBlock::FromString(const std::string content)
{
try
{
boost::regex reg("[. #[]\"\'#>]+\{(.*)}");
boost::smatch match;
//Startposition zum Suchen
std::string::const_iterator it1 = content.begin();
//Endposition zum Suchen
std::string::const_iterator it2 = content.end();
while(boost::regex_search(it1, it2, match, reg))
{
if(match[1].matched)
{
std::cout << match[1] << std::endl;
}
}
}
catch(...)
{
std::cout << "Ein unwerwarteter Fehler ist aufgetreten. Versuchen Sie es bitte erneut" << std::endl;
}
}
desweiteren die main-Funktion:
C++:
#include <iostream>
#include "include/styleblock.h"
using namespace std;
int main()
{
StyleBlock sb();
sb.FromString(".block {irgendetwas: eigenschaft} .block > .nummer2{eigenschaft: ander;}");
cout << "Hello world!" << endl;
return 0;
}
Leider gibt er mir bei der Ausführung diesen Fehler aus:
Fehler: Abfrage des Elementes »FromString« in »sb«, das vom Nicht-Klassentyp »StyleBlock()« ist|
||=== Build finished: 1 errors, 0 warnings ===|
Kann mir da vll jemand helfen?
Zuletzt bearbeitet von einem Moderator: