Sciter: F:/hsmile5/sdk/include/value.hpp Source File

Sciter  3.3.2.5
Sciter API
value.hpp
Go to the documentation of this file.
1 
18 #ifndef __value_hpp__
19 #define __value_hpp__
20 
21  #include "value.h"
22 
23  #include <string>
24  #include <functional>
25  #include "aux-slice.h"
26  #include "aux-cvt.h"
27 
28  #pragma warning( push )
29  #pragma warning(disable:4786) //identifier was truncated...
30 
31  namespace sciter
32  {
33 
34  template<typename TC>
35   inline size_t str_length(const TC* src ) {
36  if(!src) return 0;
37  size_t cnt = 0; while( *src++ ) ++cnt;
38  return cnt;
39  }
40 
41  // wide (utf16) string
42   typedef std::basic_string<WCHAR> string;
43  // ascii or utf8 string
44   typedef std::basic_string<char> astring;
45 
46   typedef std::runtime_error script_error;
47 
48  // value by key bidirectional proxy/accessor
49  class value_key_a;
50  // value by index bidirectional proxy/accessor
51  class value_idx_a;
52  class value;
53 
54 #ifdef CPP11
55  // native function that can be stored inside the value:
56  typedef std::function<value(unsigned int argc, const value* argv)> native_function_t;
57 #endif
58 
59   class value: public VALUE
60  {
61  value(void*) {} // no such thing, sorry
62  //void* get(const void* defv) const { return 0; } // and this one too is disabled
63  //void* get(const void* defv) { return 0; } // and this one too is disabled
64  public:
65   value() { ValueInit(this); }
66   ~value() { ValueClear(this); }
67   value(const value& src) { ValueInit(this); ValueCopy(this,&src); }
68   value(const VALUE& src) { ValueInit(this); ValueCopy(this,&src); }
69 
70   value& operator = (const value& src) { ValueCopy(this,&src); return *this; }
71   value& operator = (const VALUE& src) { ValueCopy(this,&src); return *this; }
72 
73   value( bool v ) { ValueInit(this); ValueIntDataSet(this, v?1:0, T_BOOL, 0); }
74   value( int v ) { ValueInit(this); ValueIntDataSet(this, v, T_INT, 0); }
75   value( double v ) { ValueInit(this); ValueFloatDataSet(this, v, T_FLOAT, 0); }
76 
77   value( const WCHAR* s, unsigned int slen = 0 ) { ValueInit(this); ValueStringDataSet(this, LPCWSTR(s), (slen || !s)? slen : (unsigned int)str_length(s), 0); }
78   value( const string& s ) { ValueInit(this); ValueStringDataSet(this, LPCWSTR(s.c_str()), UINT(s.length()), 0); }
79   value( const astring& s ) { aux::a2w as(s.c_str()); ValueInit(this); ValueStringDataSet(this, LPCWSTR(as.c_str()), UINT(as.length()), UT_STRING_SYMBOL); }
80  //value( const std::ustring& s ) { ValueInit(this); ValueStringDataSet(this, LPCWSTR(s.c_str()), UINT(s.length()), 0); }
81  //value( const std::string& s ) { aux::a2w as(s.c_str()); ValueInit(this); ValueStringDataSet(this, LPCWSTR(as.c_str()), UINT(as.length()), UT_STRING_SYMBOL); }
82   value( aux::wchars ws ) { ValueInit(this); ValueStringDataSet(this, LPCWSTR(ws.start), ws.length, 0); }
83 
84   value( aux::bytes bs ) { ValueInit(this); ValueBinaryDataSet(this, bs.start, bs.length, T_BYTES, 0); }
85 
86   value( const value* arr, unsigned n ) { ValueInit(this); for( unsigned i = 0; i < n; ++i ) set_item(int(i),arr[i]); }
87 #ifdef CPP11
88  value( const native_function_t& nfr );
89 #endif
90 
91   static value currency( INT64 v ) { value t; ValueInt64DataSet(&t, v, T_CURRENCY, 0); return t;}
92   static value date( INT64 v, bool is_utc = true /* true if ft is UTC*/ ) { value t; ValueInt64DataSet(&t, v, T_DATE, is_utc); return t;}
93 #ifdef WIN32
94  static value date( FILETIME ft, bool is_utc = true /* true if ft is UTC*/ ) { value t; ValueInt64DataSet(&t, *((INT64*)&ft), T_DATE, is_utc); return t;}
95 #endif
96   static value symbol( aux::wchars wc ) { value t; ValueInit(&t); ValueStringDataSet(&t, LPCWSTR(wc.start), wc.length , 0xFFFF); return t; }
97 
98  // string-symbol
99   value( const char* s )
100  {
101  aux::a2w as(s);
102  ValueInit(this); ValueStringDataSet(this, LPCWSTR(as.c_str()), UINT(as.length()), UT_STRING_SYMBOL);
103  }
104 
105   static value make_string( const char* s )
106  {
107  aux::a2w as(s);
108  return value(as.chars());
109  }
110   static value make_string( const WCHAR* s )
111  {
112  return value( aux::chars_of(s) );
113  }
114 
115   static value secure_string(const WCHAR* s, size_t slen)
116  {
117  value v;
118  ValueStringDataSet(&v, LPCWSTR(s), UINT(slen), UT_STRING_SECURE);
119  return v;
120  }
121 
122   static value make_error(const WCHAR* s) // returns string representing error.
123  // if such value is used as a return value from native function
124  // the script runtime will throw an error in script rather than returning that value.
125  {
126  value v;
127  if( !s ) return v;
128  ValueStringDataSet(&v, LPCWSTR(s), UINT(aux::wcslen(s)), UT_STRING_ERROR);
129  return v;
130  }
131 
132   bool is_undefined() const { return t == T_UNDEFINED; }
133   bool is_bool() const { return t == T_BOOL; }
134   bool is_int() const { return t == T_INT; }
135   bool is_float() const { return t == T_FLOAT; }
136   bool is_string() const { return t == T_STRING; }
137   bool is_symbol() const { return t == T_STRING && u == UT_STRING_SYMBOL; }
138   bool is_error_string() const { return t == T_STRING && u == UT_STRING_ERROR; }
139   bool is_date() const { return t == T_DATE; }
140   bool is_currency() const { return t == T_CURRENCY; }
141   bool is_map() const { return t == T_MAP; }
142   bool is_array() const { return t == T_ARRAY; }
143   bool is_function() const { return t == T_FUNCTION; }
144   bool is_bytes() const { return t == T_BYTES; }
145   bool is_object() const { return t == T_OBJECT; }
146   bool is_dom_element() const { return t == T_DOM_OBJECT; }
147  // if it is a native functor reference
148   bool is_native_function() const { return !!ValueIsNativeFunctor(this); }
149 
150   bool is_null() const { return t == T_NULL; }
151 
152   static value null() { value n; n.t = T_NULL; return n; }
153 
154   bool operator == (const value& rs) const
155 {
156  if( this == &rs ) return true;
157  int r = ValueCompare( this, &rs );
158  if( r == HV_OK )
159  return false;
160  else if (r == HV_OK_TRUE)
161  return true;
162  else
163  assert(false);
164  return false;
165  }
166   bool operator != (const value& rs) const
167 {
168  return !(operator==(rs));
169  }
170 
171 
172   int get(int defv) const
173  {
174  int v;
175  if(ValueIntData(this,&v) == HV_OK) return v;
176  return defv;
177  }
178   double get(double defv) const
179  {
180  double v;
181  if(ValueFloatData(this,&v) == HV_OK) return v;
182  return defv;
183  }
184   string get(const WCHAR* defv) const
185  {
186  aux::wchars wc;
187  if(ValueStringData(this, (LPCWSTR*) &wc.start,&wc.length) == HV_OK)
188  return aux::make_string(wc);
189  return string(defv);
190  }
191   aux::wchars get_chars() const
192 {
193  aux::wchars s;
194  ValueStringData(this,(LPCWSTR*)&s.start,&s.length);
195  return s;
196  }
197   aux::bytes get_bytes() const
198 {
199  aux::bytes bs;
200  ValueBinaryData(this,&bs.start,&bs.length);
201  return bs;
202  }
203 
204 #ifdef WIN32
205  FILETIME get_date() const
206 {
207  INT64 v;
208  if(ValueInt64Data(this,&v) == HV_OK) return *((FILETIME*)&v);
209  return FILETIME();
210  }
211 #endif
212 
213   bool get(bool defv) const
214  {
215  int v;
216  if(ValueIntData(this,&v) == HV_OK) return v != 0;
217  return defv;
218  }
219 
220  template<typename T> T get() const;
221 
222   static value from_string(const WCHAR* s, unsigned int len = 0, VALUE_STRING_CVT_TYPE ct = CVT_SIMPLE)
223  {
224  value t;
225  if( s )
226  {
227  if(len == 0) len = (unsigned int)str_length(s);
228  ValueFromString( &t, LPCWSTR(s), len, ct );
229  }
230  return t;
231  }
232   static value from_string(const std::basic_string<WCHAR>& s, VALUE_STRING_CVT_TYPE ct = CVT_SIMPLE)
233  {
234  return from_string(s.c_str(), (unsigned int)s.length(),ct);
235  }
236   static value from_string(aux::wchars s, VALUE_STRING_CVT_TYPE ct = CVT_SIMPLE)
237  {
238  return from_string(s.start, s.length,ct);
239  }
240 
241 
242   string to_string(int how = CVT_SIMPLE) const
243 {
244  if( how == CVT_SIMPLE && is_string() )
245  return aux::make_string(get_chars()); // do not need to allocate
246  value tv = *this;
247  ValueToString(&tv,how);
248  return aux::make_string(tv.get_chars());
249  }
250 
251   void clear()
252  {
253  ValueClear(this);
254  }
255 
256  // if it is an array or map returns number of elements there, otherwise - 0
257  // if it is a function - returns number of arguments
258   int length() const
259 {
260  int n = 0;
261  ValueElementsCount( this, &n);
262  return n;
263  }
264  // if it is an array - returns nth element
265  // if it is a map - returns nth value of the map
266  // if it is a function - returns nth argument
267  // otherwise it returns undefined value
268   value get_item(int n) const
269 {
270  value r;
271  ValueNthElementValue( this, n, &r);
272  return r;
273  }
274 
275   const value operator[](int n) const { return get_item(n); }
276  value_idx_a operator[](int n);
277 
278  // if it is a map - returns value under the key in the map
279  // if it is a function - returns value of argument with the name
280  // otherwise it returns undefined value
281   const value operator[](const value& key) const { return get_item(key); }
282  value_key_a operator[](const value& key);
283 
284   typedef std::function<bool(const value& key, const value& val)> key_value_cb;
285 
286   struct enum_cb
287  {
288  // return true to continue enumeration
289  virtual bool on(const value& key, const value& val) = 0;
290   static BOOL SC_CALLBACK _callback( LPVOID param, const VALUE* pkey, const VALUE* pval )
291  {
292  enum_cb* cb = (enum_cb*)param;
293  return cb->on( *(value*)pkey, *(value*)pval );
294  }
295 
296   static BOOL SC_CALLBACK lambda_callback( LPVOID param, const VALUE* pkey, const VALUE* pval )
297  {
298  key_value_cb* cb = (key_value_cb*)param;
299  return (*cb)(*(value*)pkey, *(value*)pval );
300  }
301 
302  };
303 
304  // enum
305   void enum_elements(enum_cb& cb) const
306 {
307  ValueEnumElements(const_cast<value*>(this), &enum_cb::_callback, &cb);
308  }
309 
310  // calls cbf for each key/value pair found in T_OBJECT or T_MAP
311   void each_key_value(key_value_cb cbf) const
312 {
313  ValueEnumElements(const_cast<value*>(this), &enum_cb::lambda_callback, &cbf);
314  }
315 
316   value key(int n) const
317 {
318  value r;
319  ValueNthElementKey( this, n, &r);
320  return r;
321  }
322 
323  // if it is an array - sets nth element expanding the array if needed
324  // if it is a map - sets nth value of the map;
325  // if it is a function - sets nth argument of the function;
326  // otherwise it converts this to array and adds v as first element.
327   void set_item(int n, const value& v)
328  {
329  ValueNthElementValueSet( this, n, &v);
330  }
331 
332   void append(const value& v)
333  {
334  ValueNthElementValueSet( this, length(), &v);
335  }
336  // if it is a map - sets named value in the map;
337  // if it is a function - sets named argument of the function;
338  // otherwise it converts this to map and adds key/v to it.
339 
340   void set_item(const value& key, const value& v)
341  {
342  ValueSetValueToKey( this,&key,&v );
343  }
344   void set_item(const char* name, const value& v)
345  {
346  value key(name);
347  ValueSetValueToKey( this,&key,&v );
348  }
349 
352   value get_item(const value& key) const
353 {
354  value r;
355  ValueGetValueOfKey( this, &key, &r);
356  return r;
357  }
358 
361   value get_item(const char* name) const
362 {
363  value key(name);
364  value r;
365  ValueGetValueOfKey( this, &key, &r);
366  return r;
367  }
368 
369  // T_OBJECT and T_DOM_OBJECT only, get value of object's data slot
370   void* get_object_data() const
371 {
372  LPCBYTE pv = 0; unsigned int dummy;
373  UINT r = ValueBinaryData(this,&pv,&dummy); r = r;
374  assert(r == HV_OK);
375  return (void*)pv;
376  }
377 
378  //
379  // Below this point are TISCRIPT/SCITER related methods
380  //
381 
382 //#if defined(HAS_TISCRIPT)
383 
384   bool is_object_native() const { return t == T_OBJECT && u == UT_OBJECT_NATIVE; }
385   bool is_object_array() const { return t == T_OBJECT && u == UT_OBJECT_ARRAY; }
386   bool is_object_function() const { return t == T_OBJECT && u == UT_OBJECT_FUNCTION; }
387   bool is_object_object() const { return t == T_OBJECT && u == UT_OBJECT_OBJECT; } // that is plain TS object
388   bool is_object_class() const { return t == T_OBJECT && u == UT_OBJECT_CLASS; } // that is TS class
389   bool is_object_error() const { return t == T_OBJECT && u == UT_OBJECT_ERROR; } // that is TS error
390 
391 
392  // T_OBJECT only, set value of object's data slot
393   void set_object_data(void* pv)
394  {
395  assert(u == UT_OBJECT_NATIVE);
396  ValueBinaryDataSet(this,(LPCBYTE)pv,1,T_OBJECT,0);
397  }
398 
399  // T_OBJECT only, class name of the object: e.g. Array, Function, etc. or custom class name.
400  //std_wstring get_object_class_name() const
401  //{
402  // assert(is_object());
403  // return get(L"");
404  //}
405  // T_OBJECT/UT_OBJECT_FUNCTION only, call TS function
406  // 'self' here is what will be known as 'this' inside the function, can be undefined for invocations of global functions
407   value call( int argc, const value* argv, value self = value(), const WCHAR* url_or_script_name = 0) const
408 {
409  value rv;
410  ValueInvoke(const_cast<value*>(this),&self,argc,argv,&rv,LPCWSTR(url_or_script_name));
411  return rv;
412  }
413 
414   value call() const { return call(0,nullptr); }
415   value call( const value& p1 ) const { return call(1,&p1); }
416   value call( const value& p1, const value& p2 ) const { value args[2] = { p1,p2 }; return call(2,args); }
417   value call( const value& p1, const value& p2, const value& p3 ) const { value args[3] = { p1,p2,p3 }; return call(3,args); }
418   value call( const value& p1, const value& p2, const value& p3, const value& p4 ) const { value args[4] = { p1,p2,p3,p4 }; return call(4,args); }
419 
421   void isolate()
422  {
423  ValueIsolate(this);
424  }
425 
426 //#endif //defined(HAS_TISCRIPT)
427 
428  // "smart" or "soft" equality test
429   static bool equal(const value& v1, const value& v2)
430  {
431  if( v1 == v2 ) return true; // strict comparison
432  switch ( v1.t > v2.t? v1.t: v2.t )
433  {
434  case T_BOOL:
435  {
436  bool const r1 = v1.get(false);
437  bool const r2 = v2.get(!r1);
438  return r1 == r2;
439  }
440  case T_INT:
441  {
442  int const r1 = v1.get(0);
443  int const r2 = v2.get(-r1);
444  return r1 == r2;
445  }
446  case T_FLOAT:
447  {
448  double const r1 = v1.get(0.0);
449  double const r2 = v2.get(-r1);
450  return r1 == r2;
451  }
452  }
453  return false;
454  }
455  };
456 
457   template<> inline int value::get<int>() const { return get(0); }
458   template<> inline unsigned value::get<unsigned>() const { return (unsigned)get(0); }
459   template<> inline bool value::get<bool>() const { return get(false); }
460   template<> inline double value::get<double>() const { return get(0.0); }
461   template<> inline float value::get<float>() const { return (float)get(0.0); }
462   template<> inline string value::get<string>() const { return to_string(); }
463  //template<> inline const value& value::get<const value&>() const { return *this; }
464   template<> inline value value::get<value>() const { return *this; }
465 
466  // value by key bidirectional proxy/accessor
467   class value_key_a
468  {
469   friend class value;
470  value& col;
471  value key;
472  value_key_a& operator=(const value_key_a& val); // no such thing
473  protected:
474   value_key_a( value& c, const value& k ): col(c),key(k) {}
475  public:
476   ~value_key_a() {}
477   value_key_a& operator= (const value& val) { col.set_item(key,val); return *this; }
478   operator const value() const { return col.get_item(key); }
479  };
480 
481  inline value_key_a
482   value::operator[](const value& key) { return value_key_a(*this, key); }
483 
484  // value by index bidirectional proxy/accessor
485   class value_idx_a
486  {
487   friend class value;
488  value& col;
489  int idx;
490  value_idx_a& operator= (const value_idx_a& val); // no such thing
491  protected:
492   value_idx_a( value& c, int i ): col(c), idx(i) {}
493  public:
494   ~value_idx_a() {}
495   value_idx_a& operator= (const value& val) { col.set_item(idx,val); return *this; }
496   operator const value() const { return col.get_item(idx); }
497  };
498 
499  inline value_idx_a
500   value::operator[](int idx) { return value_idx_a(*this, idx); }
501 
502  }
503 
504 
505 #ifdef CPP11
506  namespace sciter {
507 
508  class native_function
509  {
510  public:
511  native_function(const native_function_t& f): func(f) { assert(f); }
512  virtual ~native_function() {}
513 
514  virtual bool invoke( unsigned int argc, const VALUE* argv, VALUE* retval )
515  {
516  if( func ) {
517  ValueInit(retval);
518  value r = func(argc,static_cast<const value*>(argv));
519  ValueCopy(retval,&r);
520  return true;
521  }
522  else
523  return false;
524  }
525  native_function_t func;
526  private:
527  native_function(const native_function& f);
528  native_function& operator=(const native_function& f);
529  public:
530  static VOID invoke_impl( VOID* tag, UINT argc, const VALUE* argv, VALUE* retval)
531  {
532  native_function* self = static_cast<native_function*>(tag);
533  ValueInit(retval);
534  value r = self->func(argc,static_cast<const value*>(argv));
535  ValueCopy(retval,&r);
536  }
537  static VOID release_impl( VOID* tag )
538  {
539  native_function* self = static_cast<native_function*>(tag);
540  delete self;
541  }
542  };
543 
544  inline value::value( const native_function_t& nfr ) {
545  ValueInit(this);
546  native_function* pnf = new native_function(nfr);
547  ValueNativeFunctorSet(this, native_function::invoke_impl, native_function::release_impl, pnf );
548  }
549 
550  // vfunc(native function) is a wrapper that produces sciter::value from native function
551  // see uminimal sample
552  template<typename R>
553  inline value vfunc( R(*func)() ) {
554  return value([func](unsigned int argc, const value* argv) -> value { R r = func(); return value(r); });
555  }
556  template<typename R, typename T1>
557  inline value vfunc( R(*func)(T1 t1) ) {
558  return value([func](unsigned int argc, const value* argv) -> value {
559  R r = func(argc >= 1? argv[0].get<T1>(): T1() );
560  return value(r);
561  });
562  }
563  template<typename R, typename T1, typename T2>
564  inline value vfunc( R(*func)(T1 t1,T2 t2) ) {
565  return value([func](unsigned int argc, const value* argv) -> value {
566  R r = func(argc >= 1? argv[0].get<T1>(): T1(),
567  argc >= 2? argv[1].get<T2>(): T2() );
568  return value(r);
569  });
570  }
571  template<typename R, typename T1, typename T2, typename T3>
572  inline value vfunc( R(*func)(T1 t1,T2 t2,T3 t3) ) {
573  return value([func](unsigned int argc, const value* argv) -> value {
574  R r = func(argc >= 1? argv[0].get<T1>(): T1(),
575  argc >= 2? argv[1].get<T2>(): T2(),
576  argc >= 3? argv[2].get<T3>(): T3());
577  return value(r);
578  });
579  }
580  template<typename R, typename T1, typename T2, typename T3, typename T4>
581  inline value vfunc( R(*func)(T1 t1,T2 t2,T3 t3,T4 t4) ) {
582  return value([func](unsigned int argc, const value* argv) -> value {
583  R r = func(argc >= 1? argv[0].get<T1>(): T1(),
584  argc >= 2? argv[1].get<T2>(): T2(),
585  argc >= 3? argv[2].get<T3>(): T3(),
586  argc >= 4? argv[3].get<T4>(): T4());
587  return value(r);
588  });
589  }
590 
591  // versions of the above but for generic std::function
592  template<typename R>
593  inline value vfunc( std::function<R()> func )
594  {
595  return value([func](unsigned int argc, const value* argv) -> value {
596  R r = func(); return value(r);
597  });
598  }
599 
600  template<typename R,typename P0>
601  inline value vfunc( std::function<R(P0)> func )
602  {
603  return value([func](unsigned int argc, const value* argv) -> value {
604  R r = func(argc >= 1? argv[0].get<P0>(): P0() );
605  return value(r); });
606  }
607  template<typename R,typename P0,typename P1>
608  inline value vfunc( std::function<R(P0,P1)> func )
609  {
610  return value([func](unsigned int argc, const value* argv) -> value {
611  R r = func(argc >= 1? argv[0].get<P0>(): P0(),
612  argc >= 2? argv[1].get<P1>(): P1() );
613  return value(r); });
614  }
615 
616  template<typename R, typename P0, typename P1, typename P2>
617  inline value vfunc( std::function<R(P0,P1,P2)> func )
618  {
619  return value([func](unsigned int argc, const value* argv) -> value {
620  R r = func(argc >= 1? argv[0].get<P0>(): P0(),
621  argc >= 2? argv[1].get<P1>(): P1(),
622  argc >= 3? argv[2].get<P2>(): P2());
623  return value(r); });
624  }
625 
626  template<typename R, typename P0, typename P1, typename P2, typename P3>
627  inline value vfunc( std::function<R(P0,P1,P2,P3)> func ) {
628  return value([func](unsigned int argc, const value* argv) -> value {
629  R r = func(argc >= 1? argv[0].get<P0>(): P0(),
630  argc >= 2? argv[1].get<P1>(): P1(),
631  argc >= 3? argv[2].get<P2>(): P2(),
632  argc >= 4? argv[3].get<P3>(): P3());
633  return value(r); });
634  }
635 
636 
637  }
638 #endif
639 
640  #pragma warning( pop )
641 
642 #endif
Definition: value.h:31
bool is_bytes() const
Definition: value.hpp:144
void set_object_data(void *pv)
Definition: value.hpp:393
Definition: value.h:38
value call(const value &p1, const value &p2, const value &p3) const
Definition: value.hpp:417
bool is_function() const
Definition: value.hpp:143
value call(int argc, const value *argv, value self=value(), const WCHAR *url_or_script_name=0) const
Definition: value.hpp:407
value_key_a(value &c, const value &k)
Definition: value.hpp:474
size_t str_length(const TC *src)
Definition: value.hpp:35
bool operator!=(const value &rs) const
Definition: value.hpp:166
value(const astring &s)
Definition: value.hpp:79
UINT SCAPI ValueStringDataSet(VALUE *pval, LPCWSTR chars, UINT numChars, UINT units)
Definition: sciter-x-api.h:580
bool is_object() const
Definition: value.hpp:145
Definition: value.h:8
UINT SCAPI ValueClear(VALUE *pval)
Definition: sciter-x-api.h:574
UINT SCAPI ValueNthElementKey(const VALUE *pval, INT n, VALUE *pretval)
Definition: sciter-x-api.h:592
value(bool v)
Definition: value.hpp:73
value(aux::bytes bs)
Definition: value.hpp:84
value get_item(int n) const
Definition: value.hpp:268
UINT SCAPI ValueElementsCount(const VALUE *pval, INT *pn)
Definition: sciter-x-api.h:589
bool operator==(const value &rs) const
Definition: value.hpp:154
bool is_error_string() const
Definition: value.hpp:138
UINT SCAPI ValueEnumElements(const VALUE *pval, KeyValueCallback *penum, LPVOID param)
Definition: sciter-x-api.h:593
Definition: value.h:32
static value secure_string(const WCHAR *s, size_t slen)
Definition: value.hpp:115
void set_item(const value &key, const value &v)
Definition: value.hpp:340
value get_item(const char *name) const
Definition: value.hpp:361
value(aux::wchars ws)
Definition: value.hpp:82
std::basic_string< char > astring
Definition: value.hpp:44
value(double v)
Definition: value.hpp:75
BOOL SCAPI ValueIsNativeFunctor(const VALUE *pval)
Definition: sciter-x-api.h:600
value key(int n) const
Definition: value.hpp:316
Definition: value.h:9
void each_key_value(key_value_cb cbf) const
Definition: value.hpp:311
UINT SCAPI ValueInvoke(const VALUE *pval, VALUE *pthis, UINT argc, const VALUE *argv, VALUE *pretval, LPCWSTR url)
Definition: sciter-x-api.h:598
bool is_bool() const
Definition: value.hpp:133
static value date(INT64 v, bool is_utc=true)
Definition: value.hpp:92
bool is_float() const
Definition: value.hpp:135
static value from_string(aux::wchars s, VALUE_STRING_CVT_TYPE ct=CVT_SIMPLE)
Definition: value.hpp:236
void append(const value &v)
Definition: value.hpp:332
value(const VALUE &src)
Definition: value.hpp:68
std::runtime_error script_error
Definition: value.hpp:46
int length() const
Definition: value.hpp:258
aux::wchars get_chars() const
Definition: value.hpp:191
bool is_object_class() const
Definition: value.hpp:388
static value from_string(const WCHAR *s, unsigned int len=0, VALUE_STRING_CVT_TYPE ct=CVT_SIMPLE)
Definition: value.hpp:222
UINT SCAPI ValueIsolate(VALUE *pdst)
Definition: sciter-x-api.h:577
const BYTE * LPCBYTE
static value make_error(const WCHAR *s)
Definition: value.hpp:122
bool is_object_native() const
Definition: value.hpp:384
value(int v)
Definition: value.hpp:74
static BOOL SC_CALLBACK lambda_callback(LPVOID param, const VALUE *pkey, const VALUE *pval)
Definition: value.hpp:296
void enum_elements(enum_cb &cb) const
Definition: value.hpp:305
~value()
Definition: value.hpp:66
Definition: value.h:14
UINT SCAPI ValueNativeFunctorSet(VALUE *pval, NATIVE_FUNCTOR_INVOKE *pinvoke, NATIVE_FUNCTOR_RELEASE *prelease, VOID *tag)
Definition: sciter-x-api.h:599
bool is_undefined() const
Definition: value.hpp:132
value call(const value &p1) const
Definition: value.hpp:415
UINT SCAPI ValueCopy(VALUE *pdst, const VALUE *psrc)
Definition: sciter-x-api.h:576
bool is_object_function() const
Definition: value.hpp:386
static value currency(INT64 v)
Definition: value.hpp:91
bool is_currency() const
Definition: value.hpp:140
Definition: value.h:34
bool is_date() const
Definition: value.hpp:139
UINT SCAPI ValueInt64DataSet(VALUE *pval, INT64 data, UINT type, UINT units)
Definition: sciter-x-api.h:584
static value symbol(aux::wchars wc)
Definition: value.hpp:96
bool is_dom_element() const
Definition: value.hpp:146
UINT SCAPI ValueIntData(const VALUE *pval, INT *pData)
Definition: sciter-x-api.h:581
value_idx_a(value &c, int i)
Definition: value.hpp:492
UINT SCAPI ValueToString(VALUE *pval, UINT how)
Definition: sciter-x-api.h:596
bool is_map() const
Definition: value.hpp:141
bool is_object_object() const
Definition: value.hpp:387
void set_item(const char *name, const value &v)
Definition: value.hpp:344
Definition: value.h:36
Definition: value.h:37
bool is_object_error() const
Definition: value.hpp:389
bool is_array() const
Definition: value.hpp:142
Definition: value.h:29
const value operator[](int n) const
Definition: value.hpp:275
UINT SCAPI ValueFromString(VALUE *pval, LPCWSTR str, UINT strLength, UINT how)
Definition: sciter-x-api.h:597
value(const WCHAR *s, unsigned int slen=0)
Definition: value.hpp:77
Definition: value.h:30
virtual bool on(const value &key, const value &val)=0
const std::vector< sciter::string > & argv()
UINT SCAPI ValueFloatData(const VALUE *pval, FLOAT_VALUE *pData)
Definition: sciter-x-api.h:585
UINT u
Definition: value.h:17
Definition: value.h:26
value call() const
Definition: value.hpp:414
static BOOL SC_CALLBACK _callback(LPVOID param, const VALUE *pkey, const VALUE *pval)
Definition: value.hpp:290
value(const value &src)
Definition: value.hpp:67
UINT SCAPI ValueBinaryData(const VALUE *pval, LPCBYTE *pBytes, UINT *pnBytes)
Definition: sciter-x-api.h:587
static value null()
Definition: value.hpp:152
UINT SCAPI ValueInt64Data(const VALUE *pval, INT64 *pData)
Definition: sciter-x-api.h:583
UINT SCAPI ValueGetValueOfKey(const VALUE *pval, const VALUE *pkey, VALUE *pretval)
Definition: sciter-x-api.h:595
UINT SCAPI ValueBinaryDataSet(VALUE *pval, LPCBYTE pBytes, UINT nBytes, UINT type, UINT units)
Definition: sciter-x-api.h:588
void clear()
Definition: value.hpp:251
UINT t
Definition: value.h:16
void * get_object_data() const
Definition: value.hpp:370
bool is_object_array() const
Definition: value.hpp:385
static bool equal(const value &v1, const value &v2)
Definition: value.hpp:429
Definition: value.h:27
std::function< bool(const value &key, const value &val)> key_value_cb
Definition: value.hpp:284
static value make_string(const WCHAR *s)
Definition: value.hpp:110
bool is_string() const
Definition: value.hpp:136
UINT SCAPI ValueNthElementValueSet(VALUE *pval, INT n, const VALUE *pval_to_set)
Definition: sciter-x-api.h:591
value call(const value &p1, const value &p2) const
Definition: value.hpp:416
UINT SCAPI ValueFloatDataSet(VALUE *pval, FLOAT_VALUE data, UINT type, UINT units)
Definition: sciter-x-api.h:586
value(const string &s)
Definition: value.hpp:78
value(const char *s)
Definition: value.hpp:99
UINT SCAPI ValueInit(VALUE *pval)
Definition: sciter-x-api.h:573
void isolate()
Definition: value.hpp:421
const value operator[](const value &key) const
Definition: value.hpp:281
Definition: value.h:35
value get_item(const value &key) const
Definition: value.hpp:352
bool is_int() const
Definition: value.hpp:134
UINT SCAPI ValueIntDataSet(VALUE *pval, INT data, UINT type, UINT units)
Definition: sciter-x-api.h:582
string to_string(int how=CVT_SIMPLE) const
Definition: value.hpp:242
bool is_native_function() const
Definition: value.hpp:148
std::basic_string< WCHAR > string
Definition: value.hpp:42
UINT SCAPI ValueCompare(const VALUE *pval1, const VALUE *pval2)
Definition: sciter-x-api.h:575
UINT SCAPI ValueNthElementValue(const VALUE *pval, INT n, VALUE *pretval)
Definition: sciter-x-api.h:590
UINT SCAPI ValueSetValueToKey(VALUE *pval, const VALUE *pkey, const VALUE *pval_to_set)
Definition: sciter-x-api.h:594
value call(const value &p1, const value &p2, const value &p3, const value &p4) const
Definition: value.hpp:418
value & operator=(const value &src)
Definition: value.hpp:70
bool is_null() const
Definition: value.hpp:150
aux::bytes get_bytes() const
Definition: value.hpp:197
value(const value *arr, unsigned n)
Definition: value.hpp:86
Definition: value.h:25
static value from_string(const std::basic_string< WCHAR > &s, VALUE_STRING_CVT_TYPE ct=CVT_SIMPLE)
Definition: value.hpp:232
simple conversion of terminal values
Definition: value.h:247
void set_item(int n, const value &v)
Definition: value.hpp:327
static value make_string(const char *s)
Definition: value.hpp:105
bool is_symbol() const
Definition: value.hpp:137
Definition: value.h:28
int get(int defv) const
Definition: value.hpp:172
VALUE_STRING_CVT_TYPE
Definition: value.h:245
UINT SCAPI ValueStringData(const VALUE *pval, LPCWSTR *pChars, UINT *pNumChars)
Definition: sciter-x-api.h:579

AltStyle によって変換されたページ (->オリジナル) /