nicer code (api v3 / oldapi)
[enigma2.git] / lib / dvb_si / telephone_descriptor.cpp
1 /*
2  * $Id: telephone_descriptor.cpp,v 1.1 2003-10-17 15:36:38 tmbinc Exp $
3  *
4  * (C) 2002-2003 Andreas Oberritter <obi@saftware.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21
22 #include <lib/dvb_si/telephone_descriptor.h>
23
24 TelephoneDescriptor::TelephoneDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
25 {
26         reserved = (buffer[2] >> 6) & 0x03;
27         foreignAvailability = (buffer[2] >> 5) & 0x01;
28         connectionType = buffer[2] & 0x1f;
29         reserved2 = (buffer[3] >> 7) & 0x01;
30         countryPrefixLength = (buffer[3] >> 5) & 0x03;
31         internationalAreaCodeLength = (buffer[3] >> 2) & 0x07;
32         operatorCodeLength = buffer[3] & 0x03;
33         reserved3 = (buffer[4] >> 7) & 0x01;
34         nationalAreaCodeLength = (buffer[4] >> 4) & 0x07;
35         coreNumberLength = buffer[4] & 0x0f;
36
37         uint16_t offset = 5;
38         countryPrefix.assign((char *)&buffer[offset], countryPrefixLength);
39         offset += countryPrefixLength;
40         internationalAreaCode.assign((char *)&buffer[offset], internationalAreaCodeLength);
41         offset += internationalAreaCodeLength;
42         operatorCode.assign((char *)&buffer[offset], operatorCodeLength);
43         offset += operatorCodeLength;
44         nationalAreaCode.assign((char *)&buffer[offset], nationalAreaCodeLength);
45         offset += nationalAreaCodeLength;
46         coreNumber.assign((char *)&buffer[offset], coreNumberLength);
47 }
48
49 uint8_t TelephoneDescriptor::getForeignAvailability(void) const
50 {
51         return foreignAvailability;
52 }
53
54 uint8_t TelephoneDescriptor::getConnectionType(void) const
55 {
56         return connectionType;
57 }
58
59 std::string TelephoneDescriptor::getCountryPrefix(void) const
60 {
61         return countryPrefix;
62 }
63
64 std::string TelephoneDescriptor::getInternationalAreaCode(void) const
65 {
66         return internationalAreaCode;
67 }
68
69 std::string TelephoneDescriptor::getOperatorCode(void) const
70 {
71         return operatorCode;
72 }
73
74 std::string TelephoneDescriptor::getNationalAreaCode(void) const
75 {
76         return nationalAreaCode;
77 }
78
79 std::string TelephoneDescriptor::getCoreNumber(void) const
80 {
81         return coreNumber;
82 }
83