1 #ifndef _XECONTAINERFORMATPARSER_HPP 2 #define _XECONTAINERFORMATPARSER_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Test Executor 5 * ------------------------------------------ 6 * 7 * Copyright 2014 The Android Open Source Project 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 *//*! 22 * \file 23 * \brief Test log container format parser. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "xeDefs.hpp" 27 #include "deRingBuffer.hpp" 28 29 namespace xe 30 { 31 32 enum ContainerElement 33 { 34 CONTAINERELEMENT_INCOMPLETE = 0, 35 CONTAINERELEMENT_END_OF_STRING, 36 CONTAINERELEMENT_BEGIN_SESSION, 37 CONTAINERELEMENT_END_SESSION, 38 CONTAINERELEMENT_SESSION_INFO, 39 CONTAINERELEMENT_BEGIN_TEST_CASE_RESULT, 40 CONTAINERELEMENT_END_TEST_CASE_RESULT, 41 CONTAINERELEMENT_TERMINATE_TEST_CASE_RESULT, 42 CONTAINERELEMENT_TEST_LOG_DATA, 43 CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_BEGIN, 44 CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_END, 45 CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN, 46 CONTAINERELEMENT_TEST_RUN_PARAM_END, 47 48 CONTAINERELEMENT_LAST 49 }; 50 51 class ContainerParseError : public ParseError 52 { 53 public: ContainerParseError(const std::string & message)54 ContainerParseError(const std::string &message) : ParseError(message) 55 { 56 } 57 }; 58 59 class ContainerFormatParser 60 { 61 public: 62 ContainerFormatParser(void); 63 ~ContainerFormatParser(void); 64 65 void clear(void); 66 67 void feed(const uint8_t *bytes, size_t numBytes); 68 void advance(void); 69 getElement(void) const70 ContainerElement getElement(void) const 71 { 72 return m_element; 73 } 74 75 // SESSION_INFO 76 const char *getSessionInfoAttribute(void) const; 77 const char *getSessionInfoValue(void) const; 78 79 // BEGIN_TEST_CASE 80 const char *getTestCasePath(void) const; 81 82 // TERMINATE_TEST_CASE 83 const char *getTerminateReason(void) const; 84 85 // TEST_LOG_DATA 86 int getDataSize(void) const; 87 void getData(uint8_t *dst, int numBytes, int offset); 88 89 // TEST_RUN_PARAM 90 const char *getTestRunsParams(void) const; 91 92 private: 93 ContainerFormatParser(const ContainerFormatParser &other); 94 ContainerFormatParser &operator=(const ContainerFormatParser &other); 95 96 void error(const std::string &what); 97 98 enum State 99 { 100 STATE_AT_LINE_START, 101 STATE_CONTAINER_LINE, 102 STATE_DATA, 103 104 STATE_LAST 105 }; 106 107 enum 108 { 109 END_OF_STRING = 0, //!< End of string (0). 110 END_OF_BUFFER = 0xffffffff //!< End of current data buffer. 111 }; 112 113 int getChar(int offset) const; 114 void parseContainerLine(void); 115 void parseContainerValue(std::string &dst, int &offset) const; 116 117 ContainerElement m_element; 118 int m_elementLen; 119 State m_state; 120 std::string m_attribute; 121 std::string m_value; 122 123 de::RingBuffer<uint8_t> m_buf; 124 }; 125 126 } // namespace xe 127 128 #endif // _XECONTAINERFORMATPARSER_HPP 129