File: FociFileSaxReader.h

package info (click to toggle)
connectome-workbench 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 28,968 kB
  • ctags: 23,747
  • sloc: cpp: 260,127; ansic: 3,670; sh: 308; makefile: 146
file content (142 lines) | stat: -rw-r--r-- 4,675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

#ifndef __FOCI_FILE_SAX_READER_H__
#define __FOCI_FILE_SAX_READER_H__

/*LICENSE_START*/
/*
 *  Copyright (C) 2014  Washington University School of Medicine
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/*LICENSE_END*/

#include <stack>
#include <AString.h>
#include <stdint.h>

#include "XmlSaxParserException.h"
#include "XmlSaxParserHandlerInterface.h"


namespace caret {

    class Focus;
    class FociFile;
    class GiftiLabelTableSaxReader;
    class GiftiMetaDataSaxReader;
    class StudyMetaDataLinkSetSaxReader;
    class SurfaceProjectedItem;
    class SurfaceProjectedItemSaxReader;
    class XmlAttributes;
    class XmlException;
    
    class FociFileSaxReader : public CaretObject, public XmlSaxParserHandlerInterface {
    public:
        FociFileSaxReader(FociFile* fociFile);
        
        virtual ~FociFileSaxReader();
        
        void startElement(const AString& namespaceURI,
                          const AString& localName,
                          const AString& qName,
                          const XmlAttributes& attributes) throw (XmlSaxParserException);
        
        void endElement(const AString& namspaceURI,
                        const AString& localName,
                        const AString& qName) throw (XmlSaxParserException);
        
        void characters(const char* ch) throw (XmlSaxParserException);
        
        void fatalError(const XmlSaxParserException& e) throw (XmlSaxParserException);
        
        void warning(const XmlSaxParserException& e) throw (XmlSaxParserException);
        
        void error(const XmlSaxParserException& e) throw (XmlSaxParserException);
        
        void startDocument() throw (XmlSaxParserException);
        
        void endDocument() throw (XmlSaxParserException);
        
        
    protected:
        /// file reading states
        enum STATE {
            /// no state
            STATE_NONE,
            /// processing FociFile tag
            STATE_FOCI_FILE,
            /// processing MetaData tag
            STATE_METADATA,
            /// processing version one color table tag
            STATE_VERSION_ONE_COLOR_TABLE,
            /// processing class color table tag
            STATE_CLASS_COLOR_TABLE,
            /// processing name color table tag
            STATE_NAME_COLOR_TABLE,
            /// processing focus
            STATE_FOCUS,
            /// processing StudyMetaDataLinkSet tag
            STATE_STUDY_META_DATA_LINK_SET,
            /// processing SurfaceProjectedItem tag
            STATE_SURFACE_PROJECTED_ITEM
        };
        
        /// file reading state
        STATE m_state;
        
        /// the state stack used when reading a file
        std::stack<STATE> m_stateStack;
        
        /// the error message
        AString m_errorMessage;
        
        /// Foci file that is being read
        FociFile* m_fociFile;
        
        /// Focus that is being read
        Focus* m_focus;
        
        /// Counts projections as they are read
        int32_t m_projectionCounter;
        
        /// surface projected item that is being read
        SurfaceProjectedItem* m_surfaceProjectedItem;
        
        /// Reads a SurfaceProjectedItem
        SurfaceProjectedItemSaxReader* m_surfaceProjectedItemSaxReader;
        
        /// element text
        AString m_elementText;
        
        /// GIFTI meta data sax reader
        GiftiMetaDataSaxReader* m_metaDataSaxReader;   
        
        /// GIFTI Label Table SAX Reader;
        GiftiLabelTableSaxReader* m_labelTableSaxReader;

        /** 
         * Version 1 had only one color table that contained names and classes 
         * After reading, split into name and class color tables
         */
        GiftiLabelTable* m_versionOneColorTable;
        
        /// Study meta data link set reader
        StudyMetaDataLinkSetSaxReader* m_studyMetaDataLinkSetSaxReader;
    };

} // namespace

#endif // __FOCI_FILE_SAX_READER_H__