DbcIterator.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2015-2020, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DBC_ITERATOR_HPP
36 #define _DBC_ITERATOR_HPP
37 
38 #include <vector>
39 #include <iosfwd>
40 #include "DbcMessage.hpp"
41 
47 class DBCIterator {
48 
49  typedef std::vector<Message> messages_t;
50  // This list contains all the messages which got parsed from the DBC-File
51  messages_t messageList;
52 
53 public:
54  typedef messages_t::const_iterator const_iterator;
55 
56  // Constructors taking either a File or a Stream of a DBC-File
57  DBCIterator(const std::vector<std::string>& paths);
58  DBCIterator(const std::string& path);
59  DBCIterator(std::istream& stream);
60 
61  /*
62  * Functionality to access the Messages parsed from the File
63  * either via the iterators provided by begin() and end() or by
64  * random access operator[]
65  */
66  const_iterator begin() const { return messageList.begin(); }
67  const_iterator end() const { return messageList.end(); }
68  messages_t::const_reference operator[](std::size_t elem) const {
69  return messageList[elem];
70  }
71 
72 private:
73  void parseStream(std::istream& stream);
74 
75 };
76 
77 #endif /* _DBC_ITERATOR_HPP */
78 
const_iterator end() const
Definition: DbcIterator.hpp:67
messages_t messageList
Definition: DbcIterator.hpp:51
std::vector< Message > messages_t
Definition: DbcIterator.hpp:49
void parseStream(std::istream &stream)
Definition: DbcIterator.cpp:70
messages_t::const_iterator const_iterator
Definition: DbcIterator.hpp:54
const_iterator begin() const
Definition: DbcIterator.hpp:66
DBCIterator(const std::vector< std::string > &paths)
Definition: DbcIterator.cpp:41
messages_t::const_reference operator[](std::size_t elem) const
Definition: DbcIterator.hpp:68


dataspeed_can_tools
Author(s): Micho Radovnikovich
autogenerated on Thu Jul 9 2020 03:41:59