retdec
conversions.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_FILEFORMAT_UTILS_CONVERSIONS_H
8 #define RETDEC_FILEFORMAT_UTILS_CONVERSIONS_H
9 
10 #include <iomanip>
11 #include <sstream>
12 #include <vector>
13 
15 
16 namespace retdec {
17 namespace fileformat {
18 
26 template<typename N> bool addUniqueValue(std::vector<N> &currentValues, N newVal, std::size_t &newIndex)
27 {
28  const auto curSize = currentValues.size();
29 
30  for(std::size_t i = 0; i < curSize; ++i)
31  {
32  if(currentValues[i] == newVal)
33  {
34  newIndex = i;
35  return false;
36  }
37  }
38 
39  currentValues.push_back(newVal);
40  newIndex = curSize;
41  return true;
42 }
43 
44 std::ios_base& hexWithPrefix(std::ios_base &str);
45 std::ios_base& truncFloat(std::ios_base &str);
46 void separateStrings(std::string &str, std::vector<std::string> &words);
47 
48 } // namespace fileformat
49 } // namespace retdec
50 
51 #endif
std::ios_base & hexWithPrefix(std::ios_base &str)
Definition: conversions.cpp:17
void separateStrings(std::string &str, std::vector< std::string > &words)
Definition: conversions.cpp:46
bool addUniqueValue(std::vector< N > &currentValues, N newVal, std::size_t &newIndex)
Definition: conversions.h:26
std::ios_base & truncFloat(std::ios_base &str)
Definition: conversions.cpp:27
Definition: archive_wrapper.h:19
Simple utilities.