Coherent UI for Unreal Engine 4  2.5.5.0
A modern user interface library for games
 All Classes Functions Variables Pages
CoherentTArrayBinder.h
1 /*
2 Copyright (c) 2012 Coherent Labs Limited and/or its licensors. All
3 rights reserved in all media.
4 
5 The coded instructions, statements, computer programs, and/or related
6 material (collectively the "Data") in these files contain confidential
7 and unpublished information proprietary Coherent Labs and/or its
8 licensors, which is protected by United States of America federal
9 copyright law and by international treaties.
10 
11 This software or source code is supplied under the terms of a license
12 agreement and nondisclosure agreement with Coherent Labs Limited and may
13 not be copied, disclosed, or exploited except in accordance with the
14 terms of that agreement. The Data may not be disclosed or distributed to
15 third parties, in whole or in part, without the prior written consent of
16 Coherent Labs Limited.
17 
18 COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS
19 SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
20 HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES,
24 PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE,
31 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 #pragma once
34 
35 #include "Coherent/UI/Binding/Binder.h"
36 
37 namespace Coherent
38 {
39 namespace UI
40 {
41 
42 template <typename T, typename A>
43 void CoherentBindInternal(Binder* binder, TArray<T, A>& value)
44 {
45  binder->ArrayBegin(value.Num());
46  typedef typename TArray<T, A>::TConstIterator Iterator;
47 
48  for (Iterator i = value.CreateConstIterator(); i; ++i)
49  {
50  CoherentBindInternal(binder, *i);
51  }
52 
53  binder->ArrayEnd();
54 }
55 
56 template <typename T, typename A>
57 void CoherentBindInternal(Binder* binder, const TArray<T, A>& value)
58 {
59  binder->ArrayBegin(value.Num());
60  typedef typename TArray<T, A>::TConstIterator Iterator;
61 
62  for (Iterator i = value.CreateConstIterator(); i; ++i)
63  {
64  CoherentBindInternal(binder, *i);
65  }
66 
67  binder->ArrayEnd();
68 }
69 
70 template <typename T, typename A>
71 void CoherentReadInternal(Binder* binder, TArray<T, A>& value)
72 {
73  size_t size = binder->ReadArrayBegin();
74 
75  value.Reserve(size);
76 
77  for (size_t index = 0; index != size; )
78  {
79  binder->ReadArrayElement(index++);
80  T IndexedValue;
81  CoherentReadInternal(binder, IndexedValue);
82 
83  value.Push(IndexedValue);
84  }
85 
86  binder->ReadArrayEnd();
87 }
88 
89 
90 }
91 }