root / usrp / host / lib / legacy / db_util.cc @ 7783dc88
History | View | Annotate | Download (1.4 kB)
| 1 | 72c625f7 | jcorgan | /* -*- c++ -*- */
|
|---|---|---|---|
| 2 | 72c625f7 | jcorgan | /*
|
| 3 | 72c625f7 | jcorgan | * Copyright 2008 Free Software Foundation, Inc. |
| 4 | 72c625f7 | jcorgan | * |
| 5 | 72c625f7 | jcorgan | * This file is part of GNU Radio |
| 6 | 72c625f7 | jcorgan | * |
| 7 | 72c625f7 | jcorgan | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | 72c625f7 | jcorgan | * it under the terms of the GNU General Public License as published by |
| 9 | 72c625f7 | jcorgan | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | 72c625f7 | jcorgan | * any later version. |
| 11 | 72c625f7 | jcorgan | * |
| 12 | 72c625f7 | jcorgan | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | 72c625f7 | jcorgan | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | 72c625f7 | jcorgan | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | 72c625f7 | jcorgan | * GNU General Public License for more details. |
| 16 | 72c625f7 | jcorgan | * |
| 17 | 72c625f7 | jcorgan | * You should have received a copy of the GNU General Public License along |
| 18 | 72c625f7 | jcorgan | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | 72c625f7 | jcorgan | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | 72c625f7 | jcorgan | */ |
| 21 | 72c625f7 | jcorgan | |
| 22 | 72c625f7 | jcorgan | #ifdef HAVE_CONFIG_H
|
| 23 | 72c625f7 | jcorgan | #include <config.h> |
| 24 | 72c625f7 | jcorgan | #endif
|
| 25 | 72c625f7 | jcorgan | #include <db_util.h> |
| 26 | 72c625f7 | jcorgan | #include <sstream> |
| 27 | 72c625f7 | jcorgan | |
| 28 | 72c625f7 | jcorgan | std::string
|
| 29 | 72c625f7 | jcorgan | int_seq_to_str(std::vector<int> &seq)
|
| 30 | 72c625f7 | jcorgan | {
|
| 31 | 72c625f7 | jcorgan | //convert a sequence of integers into a string
|
| 32 | 72c625f7 | jcorgan | |
| 33 | 72c625f7 | jcorgan | std::stringstream str; |
| 34 | 72c625f7 | jcorgan | std::vector<int>::iterator i;
|
| 35 | 72c625f7 | jcorgan | for(i = seq.begin(); i != seq.end(); i++) {
|
| 36 | 72c625f7 | jcorgan | str << char((unsigned int)*i); |
| 37 | 72c625f7 | jcorgan | } |
| 38 | 72c625f7 | jcorgan | return str.str();
|
| 39 | 72c625f7 | jcorgan | } |
| 40 | 72c625f7 | jcorgan | |
| 41 | 72c625f7 | jcorgan | std::vector<int>
|
| 42 | 72c625f7 | jcorgan | str_to_int_seq(std::string str)
|
| 43 | 72c625f7 | jcorgan | {
|
| 44 | 72c625f7 | jcorgan | //convert a string to a list of integers
|
| 45 | 72c625f7 | jcorgan | std::vector<int> seq;
|
| 46 | 72c625f7 | jcorgan | std::vector<int>::iterator sitr;
|
| 47 | 72c625f7 | jcorgan | std::string::iterator i;
|
| 48 | 72c625f7 | jcorgan | for(i=str.begin(); i != str.end(); i++) {
|
| 49 | 72c625f7 | jcorgan | int a = (int)(*i); |
| 50 | 72c625f7 | jcorgan | seq.push_back(a); |
| 51 | 72c625f7 | jcorgan | } |
| 52 | 72c625f7 | jcorgan | return seq;
|
| 53 | 72c625f7 | jcorgan | } |