[go: up one dir, main page]

File: catenate.cc

package info (click to toggle)
srecord 1.55-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,728 kB
  • ctags: 2,401
  • sloc: cpp: 23,402; sh: 6,520; makefile: 3,116; awk: 208; vhdl: 15
file content (116 lines) | stat: -rw-r--r-- 2,449 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
//
// srecord - Manipulate EPROM load files
// Copyright (C) 2008, 2010 Peter Miller
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

#include <srecord/input/catenate.h>
#include <srecord/record.h>


srecord::input_catenate::~input_catenate()
{
}


srecord::input_catenate::input_catenate(const pointer &a1, const pointer &a2) :
    in1(a1),
    in2(a2)
{
    assert(!!in1);
    assert(!!in2);
}


srecord::input::pointer
srecord::input_catenate::create(const pointer &a1, const pointer &a2)
{
    return pointer(new srecord::input_catenate(a1, a2));
}


bool
srecord::input_catenate::read(srecord::record &record)
{
    while (in1)
    {
        bool ok = in1->read(record);
        if (!ok)
        {
            in1.reset();
            break;
        }
        switch (record.get_type())
        {
        case srecord::record::type_unknown:
        case srecord::record::type_data_count:
            break;

        default:
            return true;
        }
    }
    for (;;)
    {
        bool ok = in2->read(record);
        if (!ok)
            return false;
        switch (record.get_type())
        {
        case srecord::record::type_unknown:
        case srecord::record::type_data_count:
            break;

        default:
            return true;
        }
    }
}


std::string
srecord::input_catenate::filename()
    const
{
    return (in1 ? in1 : in2)->filename();
}


std::string
srecord::input_catenate::filename_and_line()
    const
{
    return (in1 ? in1 : in2)->filename_and_line();
}


const char *
srecord::input_catenate::get_file_format_name()
    const
{
    return (in1 ? in1 : in2)->get_file_format_name();
}


void
srecord::input_catenate::disable_checksum_validation()
{
    if (in1)
        in1->disable_checksum_validation();
    in2->disable_checksum_validation();
}


// vim:ts=8:sw=4:et