Boost logo

Boost Users :

Subject: [Boost-users] Boost StateChart and Template parameters
From: Etienne Philip Pretorius (icewolfhunter_at_[hidden])
Date: 2009-07-25 10:25:32


Hello List,

I would like to have a templated parse function within each of my
states. Unfortunatly I am unable to successfully create a version that
compiles, perhaps if someone could show how to get it to work.

Here is the code:

 namespace xml {

        class prolog;

        template<typename T>
        class Entity {
        public:
            virtual boost::regex regex() const = 0;
            virtual void parse(T,T) = 0;
        };

        class document
            : public boost::statechart::state_machine<
                document,
                prolog
> {
        public:
            virtual ~document(
            ) {};
        private:
            friend class prolog;
            static boost::regex character, white_space,
                                    name_start_character,
name_character, name,
                                    names, nmtoken, nmtokens, comment,
                                    process_instruction_target,
                                    process_instruction, CDATA, equal,
                                    version_info, encoding_name,
                                    encoding_declaration,
                                    standalone_document_declaration,
                                    xml_declaration, prolog;
        protected:
            document(
            ) {
                initiate();
            };

            template<typename T>
            boost::regex regex(
            ) const {
                return state_cast<const Entity<T>&>().regex();
            };

            template<typename T>
            void parse(
                T begin,
                T end
            ) {
                return state_cast<const Entity<T>&>().parse(begin,end);
            }

        };

        class prolog
            : public Entity ///<-----needs argument here but compains
the 'prolog' is NOT a template
            , public boost::statechart::simple_state<
                prolog,
                document
> {
        public:
            prolog(
            ) {};
            ~prolog(
            ) {};

            virtual boost::regex regex(
            ) const {
                return document::prolog;//FIXME...match element aswell
            };

            virtual void parse(
                T begin,
                T end
            ) {
           
            };
           
        private:
        protected:
        };
};

Any help on this will be appreciated.

Thank you all.
Etienne


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net