2010-10-03 23:04:50 +02:00
|
|
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include <vector>
|
2011-05-21 03:49:16 +02:00
|
|
|
#include "include/internal/cef_string_list.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "base/logging.h"
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
typedef std::vector<CefString> StringList;
|
2010-10-03 23:04:50 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CEF_EXPORT cef_string_list_t cef_string_list_alloc() {
|
2010-10-03 23:04:50 +02:00
|
|
|
return new StringList;
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CEF_EXPORT int cef_string_list_size(cef_string_list_t list) {
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(list);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
2010-10-03 23:04:50 +02:00
|
|
|
return impl->size();
|
|
|
|
}
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
CEF_EXPORT int cef_string_list_value(cef_string_list_t list, int index,
|
2012-01-10 00:46:23 +01:00
|
|
|
cef_string_t* value) {
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(list);
|
2010-11-22 18:49:46 +01:00
|
|
|
DCHECK(value);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
|
|
|
DCHECK_GE(index, 0);
|
|
|
|
DCHECK_LT(index, static_cast<int>(impl->size()));
|
|
|
|
if (index < 0 || index >= static_cast<int>(impl->size()))
|
2010-11-22 18:49:46 +01:00
|
|
|
return false;
|
|
|
|
const CefString& str = (*impl)[index];
|
|
|
|
return cef_string_copy(str.c_str(), str.length(), value);
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
2010-11-22 18:49:46 +01:00
|
|
|
CEF_EXPORT void cef_string_list_append(cef_string_list_t list,
|
2012-01-10 00:46:23 +01:00
|
|
|
const cef_string_t* value) {
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(list);
|
2010-11-22 18:49:46 +01:00
|
|
|
DCHECK(value);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
2010-11-22 18:49:46 +01:00
|
|
|
impl->push_back(CefString(value));
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) {
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(list);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
2010-10-03 23:04:50 +02:00
|
|
|
impl->clear();
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CEF_EXPORT void cef_string_list_free(cef_string_list_t list) {
|
2010-10-03 23:04:50 +02:00
|
|
|
DCHECK(list);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
|
|
|
delete impl;
|
2010-10-03 23:04:50 +02:00
|
|
|
}
|
2010-11-18 22:05:25 +01:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list) {
|
2010-11-18 22:05:25 +01:00
|
|
|
DCHECK(list);
|
2012-01-10 00:46:23 +01:00
|
|
|
StringList* impl = reinterpret_cast<StringList*>(list);
|
2010-11-18 22:05:25 +01:00
|
|
|
return new StringList(*impl);
|
|
|
|
}
|