2
* Copyright (C) 2010 Michael Lamothe
4
* This file is part of Me TV
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Library General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
21
#include "string_splitter.h"
22
#include "exception.h"
23
#include "me-tv-i18n.h"
25
StringSplitter::StringSplitter(const Glib::ustring& text, const char* delimiter, gboolean squeeze_repeats, gsize max_length)
27
parts = g_strsplit_set(text.c_str(), delimiter, max_length);
29
gchar** iterator = parts;
30
while (*iterator != NULL && count < max_length)
32
parts[count] = *iterator;
33
if (!squeeze_repeats || g_utf8_strlen(*iterator, -1) > 0)
41
StringSplitter::~StringSplitter()
46
const gchar* StringSplitter::get_value(guint index)
50
throw Exception(_("Index out of bounds"));
55
gint StringSplitter::get_int_value(guint index)
57
return atoi(get_value(index));
60
gsize StringSplitter::get_count() const