Viele Compilerfehler
-
// IProcessor.hpp #ifndef PROCESSOR_IPROCESSOR_HPP #define PROCESSOR_IPROCESSOR_HPP #include <string> #include <iostream> namespace TPF { /** * Interfaceklasse für beliebige Textprozessoren * * Der Template-Parameter DerivedT ist der abgeleitete Typ. * Die Behandlung von Optionen wird in die Hand dessen gelegt. * */ template <class DerivedT, typename CharT, class TraitsT> class IProcessor { public: typedef CharT CharType; typedef TraitsT TraitsType; virtual void setFlag (typename DerivedT::Option) = 0; virtual void resetFlag (typename DerivedT::Option) = 0; virtual bool getFlag (typename DerivedT::Option) const = 0; virtual void operator () (const std::basic_istream<CharT, TraitsT>&, std::basic_ostream<CharT, TraitsT>&) throw (typename DerivedT::InvalidInput) = 0; }; } // namespace Processor #endif // PROCESSOR_IPROCESSOR_HPP// Processor.hpp #ifndef PROCESSOR_PROCESSOR_HPP #define PROCESSOR_PROCESSOR_HPP // Für IProcessor #include "IProcessor.hpp" namespace TPF { /** * Basisklasse für einfache Textprozessoren * * Der eigentliche Prozess wird in einem Grammatiktyp unterhalb * von DerivedT implementiert (s. operator () ) * */ template <typename DerivedT, typename CharT = char, typename TraitsT = std::char_traits<CharT> > class Processor : public IProcessor<DerivedT, CharT, TraitsT> { public: virtual void operator () (const std::basic_istream<CharT, TraitsT>& in, std::basic_ostream<CharT, TraitsT>& out) throw (typename DerivedT::InvalidInput) { typedef std::basic_string<CharT> StringType; // Eingabe -> String StringType input (std::istreambuf_iterator<CharT> (in.rdbuf ()), std::istreambuf_iterator<CharT> ()); typename DerivedT::Grammar g (mOptions); out << g(input); } protected: typename DerivedT::OptionContainer mOptions; }; } // namespace Processor #endif // PROCESSOR_PROCESSOR_HPP// test_processor.hpp #ifndef TEST_PROCESSOR_HPP #define TEST_PROCESSOR_HPP #include <string> #include "Processor/Processor.hpp" namespace test { /** * Testprozessor */ class Processor : public TPF::Processor<typename Processor> { public: enum Option { plus1 = 0x1, minus1 = 0x2, mal2 = 0x4, durch2 = 0x8, }; typedef int OptionContainer; struct InvalidInput : std::exception { InvalidInput () { } }; class Grammar { public: Grammar (OptionContainer c) throw () { mOptions = c; } template <typename StringT> StringT operator () (StringT str) const { // Uninteressant } private: OptionContainer mOptions; }; virtual void setFlag (typename Option i) { mOptions |= i; } virtual void unsetFlag (typename Option i) { mOptions ^= i; } virtual bool getFlag (typename Option i) const { return (mOptions & i) == i; } }; } // namespace test #endif // TEST_PROCESSOR_HPPFehler:
In file included from process.cpp:5: test_processor.hpp:14: parse error before `>' token test_processor.hpp:76: parse error before `)' token test_processor.hpp:77: virtual outside class declaration test_processor.hpp: In function `void test::setFlag(...)': test_processor.hpp:78: `mOptions' undeclared (first use this function) test_processor.hpp:78: (Each undeclared identifier is reported only once for each function it appears in.) test_processor.hpp:78: `i' undeclared (first use this function) test_processor.hpp: At global scope: test_processor.hpp:80: parse error before `)' token test_processor.hpp:81: virtual outside class declaration test_processor.hpp:84: parse error before `)' token test_processor.hpp:85: virtual outside class declaration test_processor.hpp:85: non-member function `bool test::getFlag(...)' cannot have `const' method qualifier test_processor.hpp:90: parse error before `}' tokenMan verzeihe mir das Posten der vielen Dateien, aber ich weiß einfach nicht mehr weiter. Wenn ich die einzelnen mokierten Zeilen abarbeite gesellen sich neue Compilerfehler hinzu.
Das Problem ist, dass ich das Interface (IProcessor) eigentlich so beibehalten will wie es ist. Auch TPF::Processor gefiehle mir, wenn es denn mal funktionieren würde.
Ist vielleicht syntaktisch etwas nicht korrekt oder ist das ganze einfach nur total kaputt?Das Problem scheint in der Deklaration von test::Processor zu liegen, aber was genau?
-
Du hast da ein paar typename zuviel drin. Zum Beispiel in
TPF::Processor<typename Processor>oder
virtual void setFlag (typename Option i)
-
Processor/IProcessor.hpp: In instantiation of `TPF::IProcessor<test::Processor, char, std::char_traits<char> >': test_processor.hpp:15: instantiated from `TPF::Processor<test::Processor, char , std::char_traits<char> >' test_processor.hpp:15: instantiated from here Processor/IProcessor.hpp:26: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' Processor/IProcessor.hpp:27: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' Processor/IProcessor.hpp:28: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' Processor/IProcessor.hpp:33: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' Processor/Processor.hpp: In instantiation of `TPF::Processor<test::Processor, ch ar, std::char_traits<char> >': test_processor.hpp:15: instantiated from here Processor/Processor.hpp:37: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' Processor/Processor.hpp:27: invalid use of undefined type `class test::Processor' test_processor.hpp:14: forward declaration of `class test::Processor' process.cpp: In function `int main()': process.cpp:21: no match for call to `(test::Processor) (std::ifstream&, std::ofstream&)' process.cpp:22: no match for call to `(test::Processor) (std::ifstream&, std::ofstream&)'... ohne das typename im Template.
-
Zeig noch mal den Code und mach die Stellen kenntlich, die der Compiler anmeckert. Ich glaube hier hat kaum jemand lust die Zeilen zu zählen. Zusätzlich gib uns die Fehlermeldungen, wenn du mit -fmessage-length=0 kompilerst. Dann wird alles viel übersichtlicher.
-
Beim Ableiten
class Processor : public TPF::Processor<typename Processor>sind die Implementationsdetails von Processor noch nicht bekannt. Insofern kann auch TPF::Processor diese noch nicht sehen.
-
thread.push ();
-
Woran haperts denn noch?
-
Das Problem besteht weiterhin (s.o.), daran haperts.
-
.filmor schrieb:
Das Problem besteht weiterhin (s.o.), daran haperts.
*lol*
-
.filmor schrieb:
Das Problem besteht weiterhin (s.o.), daran haperts.
Und du hast alle angesprochenen Probleme entsprechend geändert?

Dann zeig mal deine aktuelle Processor Klasse.