summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/var_array.h
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 09:08:15 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 09:08:15 +0000
commit034fbf874d8f5cfd948e9b46c137b9308503fecf (patch)
treee0dd91f952058fdda15c20113c5b49fb8452e559 /ppapi/cpp/var_array.h
parente1fdb74d56350c54ec2cb2349eed00f666d6c4ae (diff)
downloadchromium_src-034fbf874d8f5cfd948e9b46c137b9308503fecf.zip
chromium_src-034fbf874d8f5cfd948e9b46c137b9308503fecf.tar.gz
chromium_src-034fbf874d8f5cfd948e9b46c137b9308503fecf.tar.bz2
Move PPB_VarArray and PPB_VarDictionary out of dev.
Note that this completely removes the dev versions of the interfaces. The discussion on moving these interfaces to stable happened here: https://codereview.chromium.org/16136009 BUG=236958 Review URL: https://chromiumcodereview.appspot.com/17005006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/var_array.h')
-rw-r--r--ppapi/cpp/var_array.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/ppapi/cpp/var_array.h b/ppapi/cpp/var_array.h
new file mode 100644
index 0000000..49373ff
--- /dev/null
+++ b/ppapi/cpp/var_array.h
@@ -0,0 +1,90 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_VAR_ARRAY_H_
+#define PPAPI_CPP_VAR_ARRAY_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/cpp/var.h"
+
+/// @file
+/// This file defines the API for interacting with array vars.
+
+namespace pp {
+
+class VarArray : public Var {
+ public:
+ /// Constructs a new array var.
+ VarArray();
+
+ /// Constructs a <code>VarArray</code> given a var for which is_array() is
+ /// true. This will refer to the same array var, but allow you to access
+ /// methods specific to arrays.
+ ///
+ /// @param[in] var An array var.
+ explicit VarArray(const Var& var);
+
+ /// Constructs a <code>VarArray</code> given a <code>PP_Var</code> of type
+ /// PP_VARTYPE_ARRAY.
+ ///
+ /// @param[in] var A <code>PP_Var</code> of type PP_VARTYPE_ARRAY.
+ explicit VarArray(const PP_Var& var);
+
+ /// Copy constructor.
+ VarArray(const VarArray& other);
+
+ virtual ~VarArray();
+
+ /// Assignment operator.
+ VarArray& operator=(const VarArray& other);
+
+ /// The <code>Var</code> assignment operator is overridden here so that we can
+ /// check for assigning a non-array var to a <code>VarArray</code>.
+ ///
+ /// @param[in] other The array var to be assigned.
+ ///
+ /// @return The resulting <code>VarArray</code> (as a <code>Var</code>&).
+ virtual Var& operator=(const Var& other);
+
+ /// Gets an element from the array.
+ ///
+ /// @param[in] index An index indicating which element to return.
+ ///
+ /// @return The element at the specified position. If <code>index</code> is
+ /// larger than or equal to the array length, an undefined var is returned.
+ Var Get(uint32_t index) const;
+
+ /// Sets the value of an element in the array.
+ ///
+ /// @param[in] index An index indicating which element to modify. If
+ /// <code>index</code> is larger than or equal to the array length, the length
+ /// is updated to be <code>index</code> + 1. Any position in the array that
+ /// hasn't been set before is set to undefined, i.e., <code>PP_Var</code> of
+ /// type <code>PP_VARTYPE_UNDEFINED</code>.
+ /// @param[in] value The value to set.
+ ///
+ /// @return A <code>bool</code> indicating whether the operation succeeds.
+ bool Set(uint32_t index, const Var& value);
+
+ /// Gets the array length.
+ ///
+ /// @return The array length.
+ uint32_t GetLength() const;
+
+ /// Sets the array length.
+ ///
+ /// @param[in] length The new array length. If <code>length</code> is smaller
+ /// than its current value, the array is truncated to the new length; any
+ /// elements that no longer fit are removed. If <code>length</code> is larger
+ /// than its current value, undefined vars are appended to increase the array
+ /// to the specified length.
+ ///
+ /// @return A <code>bool</code> indicating whether the operation succeeds.
+ bool SetLength(uint32_t length);
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_VAR_ARRAY_H_