1.3.1.2
Gameface
String.h
1 /*
2 This file is part of Cohtml, Gameface and Prysm - modern user interface technologies.
3 
4 Copyright (c) 2012-2018 Coherent Labs AD and/or its licensors. All
5 rights reserved in all media.
6 
7 The coded instructions, statements, computer programs, and/or related
8 material (collectively the "Data") in these files contain confidential
9 and unpublished information proprietary Coherent Labs and/or its
10 licensors, which is protected by United States of America federal
11 copyright law and by international treaties.
12 
13 This software or source code is supplied under the terms of a license
14 agreement and nondisclosure agreement with Coherent Labs AD and may
15 not be copied, disclosed, or exploited except in accordance with the
16 terms of that agreement. The Data may not be disclosed or distributed to
17 third parties, in whole or in part, without the prior written consent of
18 Coherent Labs AD.
19 
20 COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS
21 SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
22 HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES,
26 PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR
27 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE,
33 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 #pragma once
36 #include "Property.h"
37 #include "Binder.h"
38 
39 namespace cohtml
40 {
41 class Binder;
42 
43 template <typename Char, typename CharTraits, typename Allocator>
44 void CoherentBindInternal(Binder* binder, std::basic_string<Char, CharTraits, Allocator>& value)
45 {
46  binder->Bind(value.c_str());
47 }
48 
49 template <typename Char, typename CharTraits, typename Allocator>
50 void CoherentBindInternal(Binder* binder, const std::basic_string<Char, CharTraits, Allocator>& value)
51 {
52  binder->Bind(value.c_str());
53 }
54 
55 template <typename Char, typename CharTraits, typename Allocator>
56 void CoherentReadInternal(Binder* binder, std::basic_string<Char, CharTraits, Allocator>& value)
57 {
58  size_t size = 0;
59  const Char* buffer = nullptr;
60  binder->Read(buffer, size);
61  value.assign(buffer, size);
62 }
63 
64 template <typename CharTraits, typename Allocator>
65 struct CoherentToString<std::basic_string<char, CharTraits, Allocator>>
66 {
67  static bool Invoke(const std::basic_string<char, CharTraits, Allocator>& value, char* buffer, size_t* length)
68  {
69  if (buffer)
70  {
71  const size_t toCopy = (*length < value.size()) ? *length : value.size();
72  std::memcpy(buffer, value.data(), toCopy);
73  }
74  *length = value.size();
75  return true;
76  }
77 };
78 
79 template<typename CharTraits, typename Allocator>
80 struct TypeToElementType<std::basic_string<char, CharTraits, Allocator>>
81 {
82  static const ElementType value = ElementType::ET_String;
83 };
84 
85 }
void CoherentReadInternal(Binder *binder, ArrayType(&array)[ArraySize])
Definition: Array.h:118
void CoherentBindInternal(Binder *binder, ArrayType(&array)[ArraySize])
Definition: Array.h:80
Contains almost all Coherent namespaces, classes and functions.
Definition: CursorTypes.h:37
static bool Invoke(const std::basic_string< char, CharTraits, Allocator > &value, char *buffer, size_t *length)
Definition: String.h:67
virtual void Read(bool &value)=0
ElementType
Definition: Property.h:299
virtual void Bind(bool value)=0
Provides binding between C++ and the UI.
Definition: Binder.h:138
Definition: Property.h:183
Definition: Property.h:580
static const ElementType value
Definition: Property.h:613