4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <device_config.h>
26 using std::istringstream;
28 device_config::device_config(void)
32 device_config::~device_config(void)
36 bool device_config::get_device_id(void)
38 const string INFO_INI_PATH = "/etc/info.ini";
39 const string START_DELIMETER = "Model=";
40 const string END_DELIMETER = ";";
43 std::size_t start_pos, end_pos;
46 in_file.open(INFO_INI_PATH);
48 if (!in_file.is_open())
51 while (!in_file.eof()) {
52 getline(in_file, line);
53 start_pos = line.find(START_DELIMETER);
55 if (start_pos == std::string::npos)
58 start_pos = start_pos + START_DELIMETER.size();
59 end_pos = line.find(END_DELIMETER, start_pos);
61 if (end_pos == std::string::npos)
64 m_device_id = line.substr(start_pos, end_pos - start_pos);