1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "query_param_generator.h"
23 QPGenerator::QPGenerator(const std::map<std::string, std::vector<std::string>> &queryParams)
25 for (auto entry : queryParams)
27 if (entry.second.size())
30 detail.key.assign(entry.first.c_str());
31 detail.values = entry.second;
33 m_qpDetails.push_back(detail);
38 bool QPGenerator::hasNext()
40 if (m_qpDetails.size() &&
41 (m_qpDetails[0].index < m_qpDetails[0].values.size()))
49 std::map<std::string, std::string> QPGenerator::next()
51 std::map<std::string, std::string> queryParams;
55 for (auto ele : m_qpDetails)
56 queryParams[ele.key] = ele.values[ele.index];
58 for (int index = m_qpDetails.size() - 1; index >= 0; index--)
60 m_qpDetails[index].index++;
61 if (m_qpDetails[index].index >= m_qpDetails[index].values.size()) // Boundary check
65 m_qpDetails[index].index = 0;