source: cfg_oil/trunk/toppers/s_record.hpp@ 8

Last change on this file since 8 was 8, checked in by msugi, 13 years ago

ディレクトリ構造の作成,ソース一式とReleaseビルドのコミット.

File size: 4.8 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2005-2008 by TAKAGI Nobuhisa
6 *
7 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
8 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
9 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
10 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
11 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
12 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
13 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
14 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
15ƒƒ“ƒgi—˜—p
16 * ŽÒƒ}ƒjƒ…
17ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
18 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
19 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
20 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
21 * ‚ƁD
22 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
23ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
24ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
25 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
26 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
27 * •ñ‚·‚邱‚ƁD
28 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
29 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
30 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
31 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
32 * –Ɛӂ·‚邱‚ƁD
33 *
34 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
35 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
36 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
37 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
38 * ‚̐ӔC‚𕉂í‚È‚¢D
39 *
40 */
41
42/*!
43 * \file toppers/s_record.hpp
44 * \brief ƒ‚ƒgƒ[ƒ‰SƒŒƒR[ƒh‚ðˆµ‚¤‚½‚߂̐錾’è‹`
45 *
46 * ‚±‚̃tƒ@ƒCƒ‹‚Å’è‹`‚³‚ê‚éƒNƒ‰ƒX
47 * \code
48 * class s_record;
49 * struct s_record::record;
50 * class s_record::format_error;
51 * class s_record::checksum_error;
52 * \endcode
53 */
54#ifndef TOPPERS_S_RECORD_HPP_
55#define TOPPERS_S_RECORD_HPP_
56
57#include "toppers/config.hpp"
58#include <iosfwd>
59#include <string>
60#include <vector>
61#include <utility>
62#include <stdexcept>
63#include <boost/cstdint.hpp>
64
65namespace toppers
66{
67
68 /*!
69 * \class s_record s_record.hpp "toppers/s_recored.hpp"
70 * \brief ƒ‚ƒgƒ[ƒ‰SƒŒƒR[ƒh‚ðˆµ‚¤‚½‚߂̃Nƒ‰ƒX
71 *
72 * \sa s_record::record, s_record::format_error, s_record::checksum_error
73 */
74 class s_record
75 {
76 public:
77 typedef std::pair< unsigned long, std::vector< unsigned char > > value_type;
78 typedef std::vector< value_type >::size_type size_type;
79
80 /*!
81 * \struct record s_record.hpp "toppers/s_record.hpp"
82 * \brief SƒŒƒR[ƒh‚Ì‚PsƒŒƒR[ƒhî•ñ‚ðŠi”[‚·‚邽‚߂̍\‘¢‘Ì
83 */
84 struct record
85 {
86 int type;
87 int length;
88 unsigned long address;
89 std::vector< unsigned char > data;
90 int checksum;
91 };
92
93 /*!
94 * \class data_error s_record.hpp "toppers/s_record.hpp"
95 * \brief SƒŒƒR[ƒh‚̃f[ƒ^ƒGƒ‰[—áŠOƒNƒ‰ƒX
96 */
97 class data_error : public std::runtime_error
98 {
99 public:
100 data_error() : std::runtime_error( "S-record data error" ) {}
101 };
102 /*!
103 * \class format_error s_record.hpp "toppers/s_record.hpp"
104 * \brief SƒŒƒR[ƒh‚̏‘Ž®ƒGƒ‰[—áŠOƒNƒ‰ƒX
105 */
106 class format_error : public std::runtime_error
107 {
108 public:
109 format_error() : std::runtime_error( "S-record format error" ) {}
110 };
111 /*!
112 * \class checksum_error s_record.hpp "toppers/s_record.hpp"
113 * \brief SƒŒƒR[ƒh‚̃`ƒFƒbƒNƒTƒ€ƒGƒ‰[—áŠOƒNƒ‰ƒX
114 */
115 class checksum_error : public std::runtime_error
116 {
117 public:
118 checksum_error() : std::runtime_error( "S-record checksum error" ) {}
119 };
120
121 /*!
122 * \brief ƒfƒtƒHƒ‹ƒgƒRƒ“ƒXƒgƒ‰ƒNƒ^
123 */
124 s_record() : cache_( data_.end() ) {}
125 /*!
126 * \brief ƒRƒ“ƒXƒgƒ‰ƒNƒ^
127 * \param istr “ü—̓XƒgƒŠ[ƒ€
128 *
129 * s_record ƒNƒ‰ƒX‚̐¶¬‚Æ“¯Žž‚Ƀf[ƒ^‚̃[ƒh‚ðs‚¢‚Ü‚·B
130 */
131 explicit s_record( std::istream& istr ) { load( istr ); }
132 /*!
133 * \brief ƒfƒXƒgƒ‰ƒNƒ^
134 */
135 virtual ~s_record() {}
136
137 void load( std::istream& istr );
138 int operator[]( size_type address ) const;
139 boost::uintmax_t get_value( std::size_t base, std::size_t size, bool little_endian ) const;
140 unsigned long lower_bound() const;
141 unsigned long upper_bound() const;
142 protected:
143 static record const read_record( std::string const& rec_buf );
144 static int xdigit_to_int( int ch );
145 private:
146 std::vector< value_type > data_;
147 mutable std::vector< value_type >::const_iterator cache_;
148 };
149
150}
151
152#endif // ! TOPPERS_S_RECORD_HPP_
Note: See TracBrowser for help on using the repository browser.