mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Branch CEF3 files from /branches/cef3 to /trunk/cef3 (issue #564).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@571 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
58
libcef/common/string_list_impl.cc
Normal file
58
libcef/common/string_list_impl.cc
Normal file
@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
|
||||
#include <vector>
|
||||
#include "include/internal/cef_string_list.h"
|
||||
#include "base/logging.h"
|
||||
|
||||
typedef std::vector<CefString> StringList;
|
||||
|
||||
CEF_EXPORT cef_string_list_t cef_string_list_alloc() {
|
||||
return new StringList;
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_list_size(cef_string_list_t list) {
|
||||
DCHECK(list);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
return impl->size();
|
||||
}
|
||||
|
||||
CEF_EXPORT int cef_string_list_value(cef_string_list_t list, int index,
|
||||
cef_string_t* value) {
|
||||
DCHECK(list);
|
||||
DCHECK(value);
|
||||
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()))
|
||||
return false;
|
||||
const CefString& str = (*impl)[index];
|
||||
return cef_string_copy(str.c_str(), str.length(), value);
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_list_append(cef_string_list_t list,
|
||||
const cef_string_t* value) {
|
||||
DCHECK(list);
|
||||
DCHECK(value);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
impl->push_back(CefString(value));
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_list_clear(cef_string_list_t list) {
|
||||
DCHECK(list);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
impl->clear();
|
||||
}
|
||||
|
||||
CEF_EXPORT void cef_string_list_free(cef_string_list_t list) {
|
||||
DCHECK(list);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
delete impl;
|
||||
}
|
||||
|
||||
CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list) {
|
||||
DCHECK(list);
|
||||
StringList* impl = reinterpret_cast<StringList*>(list);
|
||||
return new StringList(*impl);
|
||||
}
|
Reference in New Issue
Block a user