Add rule for 'All devices apps' when access rule is empty.
[platform/core/connectivity/smartcard-service.git] / common / NumberStream.cpp
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "NumberStream.h"
18
19 namespace smartcard_service_api
20 {
21         NumberStream::NumberStream(const ByteArray &T)
22         {
23                 assign(T.getBuffer(), T.size());
24         }
25
26         unsigned int NumberStream::getBigEndianNumber() const
27         {
28                 return getBigEndianNumber(*this);
29         }
30
31         unsigned int NumberStream::getLittleEndianNumber() const
32         {
33                 return getLittleEndianNumber(*this);
34         }
35
36         NumberStream &NumberStream::operator =(const ByteArray &T)
37         {
38                 if (this != &T)
39                 {
40                         assign(T.getBuffer(), T.size());
41                 }
42
43                 return *this;
44         }
45
46         NumberStream &NumberStream::operator =(const NumberStream &T)
47         {
48                 if (this != &T)
49                 {
50                         assign(T.getBuffer(), T.size());
51                 }
52
53                 return *this;
54         }
55
56         unsigned int NumberStream::getBigEndianNumber(const ByteArray &T)
57         {
58                 int i, len;
59                 unsigned int result = 0;
60
61                 len = (T.size() < 4) ? T.size() : 4;
62
63                 for (i = 0; i < len; i++)
64                 {
65                         result = (result << 8) | T.at(i);
66                 }
67
68                 return result;
69         }
70
71         unsigned int NumberStream::getLittleEndianNumber(const ByteArray &T)
72         {
73                 int i, len;
74                 unsigned int result = 0;
75
76                 len = (T.size() < 4) ? T.size() : 4;
77
78                 for (i = 0; i < len; i++)
79                 {
80                         result = result | (T.at(i) << (i * 8));
81                 }
82
83                 return result;
84         }
85
86 } /* namespace smartcard_service_api */