blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
d86ae79d4f9e00696174bf66227d7e210505fc8f
d0d5fac9b0635f75dc211ceb68d16e9b4399bb11
/src/hiphop-php/hphp/system/gen/php/classes/splfile.cpp
67af964f8c25c5c1e3e17571834435efec2a1b3a
[ "PHP-3.01", "Zend-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
NeoTim/hiphop-php-docker
2ebf60db2c08bb93aef94ec9fab4d548f8f09bf4
51ae1a35e387c05f936cf59ed9d23965554d4b87
refs/heads/master
2020-04-16T09:17:51.394473
2017-12-03T18:45:36
2017-12-03T18:45:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
72,595
cpp
/* +----------------------------------------------------------------------+ | HipHop for PHP | +----------------------------------------------------------------------+ | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ // @generated by HipHop Compiler #include <runtime/base/hphp_system.h> #include <system/gen/sys/literal_strings_remap.h> #include <system/gen/sys/scalar_arrays_remap.h> #include <php/classes/splfile.fws.h> #include <php/classes/splfile.h> // Dependencies #include <php/classes/iterator.h> #include <runtime/ext/ext.h> #include <runtime/eval/eval.h> namespace hphp_impl_starter {} namespace HPHP { /////////////////////////////////////////////////////////////////////////////// /* preface starts */ /* preface finishes */ /* SRC: classes/splfile.php line 384 */ const int64 q_SplFileObject$$DROP_NEW_LINE = 1L; const int64 q_SplFileObject$$READ_AHEAD = 2L; const int64 q_SplFileObject$$SKIP_EMPTY = 6L; const int64 q_SplFileObject$$READ_CSV = 8L; IMPLEMENT_CLASS_NO_DEFAULT_SWEEP(SplFileObject) extern const InstanceOfInfo cw_SplFileObject$$instanceof_table[] = { {0x4682C3C3,1,"SplFileInfo",&cw_SplFileInfo}, {0x6E55CB64,1,"SeekableIterator",(const ObjectStaticCallbacks*)2}, {0x4297F386,1,"RecursiveIterator",(const ObjectStaticCallbacks*)2}, {0x2225C327,1,"SplFileObject",&cw_SplFileObject}, {0x5CB957E8,1,"Iterator",(const ObjectStaticCallbacks*)2}, {0x27F2782C,1,"Traversable",(const ObjectStaticCallbacks*)2}, }; const int cw_SplFileObject$$instanceof_index[] = { 15, -1,-1,-1,0,1,-1,2,3, 4,-1,-1,-1,5,-1,-1,-1, }; extern const CallInfo ci_SplFileObject$$ftruncate = { (void*)&c_SplFileObject::i_ftruncate, (void*)&c_SplFileObject::ifa_ftruncate, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$valid = { (void*)&c_SplFileObject::i_valid, (void*)&c_SplFileObject::ifa_valid, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fgetc = { (void*)&c_SplFileObject::i_fgetc, (void*)&c_SplFileObject::ifa_fgetc, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fgetss = { (void*)&c_SplFileObject::i_fgetss, (void*)&c_SplFileObject::ifa_fgetss, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$current = { (void*)&c_SplFileObject::i_current, (void*)&c_SplFileObject::ifa_current, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$next = { (void*)&c_SplFileObject::i_next, (void*)&c_SplFileObject::ifa_next, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$getchildren = { (void*)&c_SplFileObject::i_getchildren, (void*)&c_SplFileObject::ifa_getchildren, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fseek = { (void*)&c_SplFileObject::i_fseek, (void*)&c_SplFileObject::ifa_fseek, 2, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$setflags = { (void*)&c_SplFileObject::i_setflags, (void*)&c_SplFileObject::ifa_setflags, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fflush = { (void*)&c_SplFileObject::i_fflush, (void*)&c_SplFileObject::ifa_fflush, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$flock = { (void*)&c_SplFileObject::i_flock, (void*)&c_SplFileObject::ifa_flock, 2, 4, 0x0000000000000002L}; extern const CallInfo ci_SplFileObject$$seek = { (void*)&c_SplFileObject::i_seek, (void*)&c_SplFileObject::ifa_seek, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fgets = { (void*)&c_SplFileObject::i_fgets, (void*)&c_SplFileObject::ifa_fgets, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$getflags = { (void*)&c_SplFileObject::i_getflags, (void*)&c_SplFileObject::ifa_getflags, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fgetcsv = { (void*)&c_SplFileObject::i_fgetcsv, (void*)&c_SplFileObject::ifa_fgetcsv, 3, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$ftell = { (void*)&c_SplFileObject::i_ftell, (void*)&c_SplFileObject::ifa_ftell, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$rewind = { (void*)&c_SplFileObject::i_rewind, (void*)&c_SplFileObject::ifa_rewind, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$setmaxlinelen = { (void*)&c_SplFileObject::i_setmaxlinelen, (void*)&c_SplFileObject::ifa_setmaxlinelen, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fstat = { (void*)&c_SplFileObject::i_fstat, (void*)&c_SplFileObject::ifa_fstat, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$getcsvcontrol = { (void*)&c_SplFileObject::i_getcsvcontrol, (void*)&c_SplFileObject::ifa_getcsvcontrol, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$haschildren = { (void*)&c_SplFileObject::i_haschildren, (void*)&c_SplFileObject::ifa_haschildren, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fpassthru = { (void*)&c_SplFileObject::i_fpassthru, (void*)&c_SplFileObject::ifa_fpassthru, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$__construct = { (void*)&c_SplFileObject::i___construct, (void*)&c_SplFileObject::ifa___construct, 4, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$getmaxlinelen = { (void*)&c_SplFileObject::i_getmaxlinelen, (void*)&c_SplFileObject::ifa_getmaxlinelen, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fwrite = { (void*)&c_SplFileObject::i_fwrite, (void*)&c_SplFileObject::ifa_fwrite, 2, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$key = { (void*)&c_SplFileObject::i_key, (void*)&c_SplFileObject::ifa_key, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$eof = { (void*)&c_SplFileObject::i_eof, (void*)&c_SplFileObject::ifa_eof, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$fscanf = { (void*)&c_SplFileObject::i_fscanf, (void*)&c_SplFileObject::ifa_fscanf, 1, 5, 0x0000000000000000L}; extern const CallInfo ci_SplFileObject$$setcsvcontrol = { (void*)&c_SplFileObject::i_setcsvcontrol, (void*)&c_SplFileObject::ifa_setcsvcontrol, 3, 4, 0x0000000000000000L}; Variant c_SplFileObject::i___construct(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa___construct); } Variant c_SplFileObject::i_current(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_current); } Variant c_SplFileObject::i_eof(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_eof); } Variant c_SplFileObject::i_fflush(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fflush); } Variant c_SplFileObject::i_fgetc(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fgetc); } Variant c_SplFileObject::i_fgetcsv(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fgetcsv); } Variant c_SplFileObject::i_fgets(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fgets); } Variant c_SplFileObject::i_fgetss(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fgetss); } Variant c_SplFileObject::i_flock(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_flock); } Variant c_SplFileObject::i_fpassthru(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fpassthru); } Variant c_SplFileObject::i_fscanf(MethodCallPackage &mcp, CArrRef params) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::i_dummy(mcp, params, i_fscanf, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); int count ATTRIBUTE_UNUSED = params.size(); if (UNLIKELY(count < 1)) return throw_missing_arguments("SplFileObject::fscanf", count+1, 1); { ArrayData *ad(params.get()); ssize_t pos = ad ? ad->iter_begin() : ArrayData::invalid_index; CVarRef arg0((ad->getValue(pos))); const Array &p(count > 1 ? params.slice(1, count - 1, false) : Array()); return (self->t_fscanf(count, arg0, p)); } } Variant c_SplFileObject::i_fseek(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fseek); } Variant c_SplFileObject::i_fstat(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fstat); } Variant c_SplFileObject::i_ftell(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_ftell); } Variant c_SplFileObject::i_ftruncate(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_ftruncate); } Variant c_SplFileObject::i_fwrite(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_fwrite); } Variant c_SplFileObject::i_getchildren(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getchildren); } Variant c_SplFileObject::i_getcsvcontrol(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getcsvcontrol); } Variant c_SplFileObject::i_getflags(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getflags); } Variant c_SplFileObject::i_getmaxlinelen(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getmaxlinelen); } Variant c_SplFileObject::i_haschildren(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_haschildren); } Variant c_SplFileObject::i_key(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_key); } Variant c_SplFileObject::i_next(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_next); } Variant c_SplFileObject::i_rewind(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_rewind); } Variant c_SplFileObject::i_seek(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_seek); } Variant c_SplFileObject::i_setcsvcontrol(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_setcsvcontrol); } Variant c_SplFileObject::i_setflags(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_setflags); } Variant c_SplFileObject::i_setmaxlinelen(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_setmaxlinelen); } Variant c_SplFileObject::i_valid(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_valid); } Variant NEVER_INLINE c_SplFileObject::ifa___construct(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa___construct, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count < 1 || count > 4)) return throw_wrong_arguments("SplFileObject::__construct", count, 1, 4, 2); CVarRef arg0(a0); if (count <= 1) return (self->t___construct(arg0), null); CVarRef arg1(a1); if (count <= 2) return (self->t___construct(arg0, arg1), null); CVarRef arg2(a2); if (count <= 3) return (self->t___construct(arg0, arg1, arg2), null); CVarRef arg3(a3); return (self->t___construct(arg0, arg1, arg2, arg3), null); } Variant NEVER_INLINE c_SplFileObject::ifa_current(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_current, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::current", 0, 1); return (self->t_current()); } Variant NEVER_INLINE c_SplFileObject::ifa_eof(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_eof, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::eof", 0, 1); return (self->t_eof()); } Variant NEVER_INLINE c_SplFileObject::ifa_fflush(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fflush, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::fflush", 0, 1); return (self->t_fflush()); } Variant NEVER_INLINE c_SplFileObject::ifa_fgetc(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fgetc, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::fgetc", 0, 1); return (self->t_fgetc()); } Variant NEVER_INLINE c_SplFileObject::ifa_fgetcsv(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fgetcsv, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 3)) return throw_toomany_arguments("SplFileObject::fgetcsv", 3, 1); if (count <= 0) return (self->t_fgetcsv()); CVarRef arg0(a0); if (count <= 1) return (self->t_fgetcsv(arg0)); CVarRef arg1(a1); if (count <= 2) return (self->t_fgetcsv(arg0, arg1)); CVarRef arg2(a2); return (self->t_fgetcsv(arg0, arg1, arg2)); } Variant NEVER_INLINE c_SplFileObject::ifa_fgets(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fgets, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::fgets", 0, 1); return (self->t_fgets()); } Variant NEVER_INLINE c_SplFileObject::ifa_fgetss(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fgetss, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileObject::fgetss", count, 1, 1, 1); CVarRef arg0(a0); return (self->t_fgetss(arg0)); } Variant NEVER_INLINE c_SplFileObject::ifa_flock(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_flock, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 2)) return throw_wrong_arguments("SplFileObject::flock", count, 2, 2, 1); CVarRef arg0(a0); VRefParam arg1(vref(a1)); return (self->t_flock(arg0, arg1)); } Variant NEVER_INLINE c_SplFileObject::ifa_fpassthru(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fpassthru, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::fpassthru", 0, 1); return (self->t_fpassthru()); } Variant NEVER_INLINE c_SplFileObject::ifa_fscanf(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fscanf, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count < 1)) return throw_missing_arguments("SplFileObject::fscanf", count+1, 1); CVarRef arg0(a0); Array p; if (count >= 2) p.append(a1); if (count >= 3) p.append(a2); if (count >= 4) p.append(a3); if (count >= 5) p.append(a4); if (count >= 6) p.append(a5); return (self->t_fscanf(count, arg0, p)); } Variant NEVER_INLINE c_SplFileObject::ifa_fseek(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fseek, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 2)) return throw_wrong_arguments("SplFileObject::fseek", count, 2, 2, 1); CVarRef arg0(a0); CVarRef arg1(a1); return (self->t_fseek(arg0, arg1)); } Variant NEVER_INLINE c_SplFileObject::ifa_fstat(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fstat, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::fstat", 0, 1); return (self->t_fstat()); } Variant NEVER_INLINE c_SplFileObject::ifa_ftell(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_ftell, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::ftell", 0, 1); return (self->t_ftell()); } Variant NEVER_INLINE c_SplFileObject::ifa_ftruncate(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_ftruncate, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileObject::ftruncate", count, 1, 1, 1); CVarRef arg0(a0); return (self->t_ftruncate(arg0)); } Variant NEVER_INLINE c_SplFileObject::ifa_fwrite(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_fwrite, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 2)) return throw_wrong_arguments("SplFileObject::fwrite", count, 2, 2, 1); CVarRef arg0(a0); CVarRef arg1(a1); return (self->t_fwrite(arg0, arg1)); } Variant NEVER_INLINE c_SplFileObject::ifa_getchildren(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getchildren, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::getChildren", 0, 1); return (self->t_getchildren()); } Variant NEVER_INLINE c_SplFileObject::ifa_getcsvcontrol(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getcsvcontrol, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::getCsvControl", 0, 1); return (self->t_getcsvcontrol()); } Variant NEVER_INLINE c_SplFileObject::ifa_getflags(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getflags, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::getFlags", 0, 1); return (self->t_getflags()); } Variant NEVER_INLINE c_SplFileObject::ifa_getmaxlinelen(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getmaxlinelen, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::getMaxLineLen", 0, 1); return (self->t_getmaxlinelen()); } Variant NEVER_INLINE c_SplFileObject::ifa_haschildren(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_haschildren, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::hasChildren", 0, 1); return (self->t_haschildren()); } Variant NEVER_INLINE c_SplFileObject::ifa_key(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_key, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::key", 0, 1); return (self->t_key()); } Variant NEVER_INLINE c_SplFileObject::ifa_next(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_next, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::next", 0, 1); return (self->t_next(), null); } Variant NEVER_INLINE c_SplFileObject::ifa_rewind(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_rewind, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::rewind", 0, 1); return (self->t_rewind(), null); } Variant NEVER_INLINE c_SplFileObject::ifa_seek(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_seek, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileObject::seek", count, 1, 1, 1); CVarRef arg0(a0); return (self->t_seek(arg0), null); } Variant NEVER_INLINE c_SplFileObject::ifa_setcsvcontrol(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_setcsvcontrol, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 3)) return throw_toomany_arguments("SplFileObject::setCsvControl", 3, 1); if (count <= 0) return (self->t_setcsvcontrol(), null); CVarRef arg0(a0); if (count <= 1) return (self->t_setcsvcontrol(arg0), null); CVarRef arg1(a1); if (count <= 2) return (self->t_setcsvcontrol(arg0, arg1), null); CVarRef arg2(a2); return (self->t_setcsvcontrol(arg0, arg1, arg2), null); } Variant NEVER_INLINE c_SplFileObject::ifa_setflags(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_setflags, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileObject::setFlags", count, 1, 1, 1); CVarRef arg0(a0); return (self->t_setflags(arg0), null); } Variant NEVER_INLINE c_SplFileObject::ifa_setmaxlinelen(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_setmaxlinelen, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileObject::setMaxLineLen", count, 1, 1, 1); CVarRef arg0(a0); return (self->t_setmaxlinelen(arg0), null); } Variant NEVER_INLINE c_SplFileObject::ifa_valid(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_valid, coo_SplFileObject); } c_SplFileObject *self ATTRIBUTE_UNUSED (static_cast<c_SplFileObject*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileObject::valid", 0, 1); return (self->t_valid()); } extern const MethodCallInfoTable cw_SplFileObject$$call_info_table[] = { { 0x103A5F44, 1, 11, "getChildren", &ci_SplFileObject$$getchildren }, { 0x65C03C46, 0, 4, "seek", &ci_SplFileObject$$seek }, { 0x22A9C646, 1, 13, "setMaxLineLen", &ci_SplFileObject$$setmaxlinelen }, { 0x7BD8E147, 1, 8, "setFlags", &ci_SplFileObject$$setflags }, { 0x1B62E28A, 1, 6, "fwrite", &ci_SplFileObject$$fwrite }, { 0x6C173D4B, 1, 13, "getMaxLineLen", &ci_SplFileObject$$getmaxlinelen }, { 0x0B4BCAD0, 1, 5, "fseek", &ci_SplFileObject$$fseek }, { 0x4991C291, 1, 7, "current", &ci_SplFileObject$$current }, { 0x7FCADC12, 1, 5, "ftell", &ci_SplFileObject$$ftell }, { 0x0053ACD3, 1, 6, "fflush", &ci_SplFileObject$$fflush }, { 0x6D53C415, 1, 5, "fstat", &ci_SplFileObject$$fstat }, { 0x3A8BA199, 1, 11, "hasChildren", &ci_SplFileObject$$haschildren }, { 0x1613965B, 1, 9, "fpassthru", &ci_SplFileObject$$fpassthru }, { 0x51A5071C, 1, 4, "next", &ci_SplFileObject$$next }, { 0x033D201F, 1, 13, "setCsvControl", &ci_SplFileObject$$setcsvcontrol }, { 0x125D8620, 1, 5, "flock", &ci_SplFileObject$$flock }, { 0x3E76C827, 1, 6, "fscanf", &ci_SplFileObject$$fscanf }, { 0x07B45928, 0, 3, "eof", &ci_SplFileObject$$eof }, { 0x09861BA8, 1, 6, "fgetss", &ci_SplFileObject$$fgetss }, { 0x0A07B1AB, 1, 7, "fgetcsv", &ci_SplFileObject$$fgetcsv }, { 0x3A40C6ED, 1, 11, "__construct", &ci_SplFileObject$$__construct }, { 0x46D74F2E, 0, 13, "getCsvControl", &ci_SplFileObject$$getcsvcontrol }, { 0x641E8DAE, 1, 8, "getFlags", &ci_SplFileObject$$getflags }, { 0x22ED5531, 0, 5, "fgets", &ci_SplFileObject$$fgets }, { 0x4D5C8831, 1, 6, "rewind", &ci_SplFileObject$$rewind }, { 0x35A80033, 1, 5, "valid", &ci_SplFileObject$$valid }, { 0x21B23D34, 1, 3, "key", &ci_SplFileObject$$key }, { 0x4BF2F1B6, 1, 5, "fgetc", &ci_SplFileObject$$fgetc }, { 0x3016EE7A, 1, 9, "ftruncate", &ci_SplFileObject$$ftruncate }, }; extern const int cw_SplFileObject$$call_info_index[] = { 63, -1,-1,-1,-1,0,-1,1,3, -1,-1,4,5,-1,-1,-1,-1, 6,7,8,9,-1,10,-1,-1, -1,11,-1,12,13,-1,-1,14, 15,-1,-1,-1,-1,-1,-1,16, 17,-1,-1,19,-1,20,21,-1, -1,23,-1,25,26,-1,27,-1, -1,-1,28,-1,-1,-1,-1,-1, }; c_SplFileObject *c_SplFileObject::create(CVarRef v_filename, CVarRef v_open_mode // = NAMVAR(s_sys_svs3bf6014b, "r") , CVarRef v_use_include_path // = false_varNR , CVarRef v_context // = null_variant ) { CountableHelper h(this); init(); t___construct(v_filename, v_open_mode, v_use_include_path, v_context); return this; } extern const MethodCallInfoTable cw_SplFileObject$$call_info_table[]; extern const int cw_SplFileObject$$call_info_index[]; extern const InstanceOfInfo cw_SplFileObject$$instanceof_table[]; extern const int cw_SplFileObject$$instanceof_index[]; const ObjectStaticCallbacks cw_SplFileObject = { (ObjectData*(*)(ObjectData*))coo_SplFileObject, cw_SplFileObject$$call_info_table,cw_SplFileObject$$call_info_index, cw_SplFileObject$$instanceof_table,cw_SplFileObject$$instanceof_index, &c_SplFileObject::s_class_name, &c_SplFileObject::os_prop_table,&ci_SplFileObject$$__construct,0,&cw_SplFileInfo,0x0, &c_SplFileObject::s_cls }; /* SRC: classes/splfile.php line 392 */ void c_SplFileObject::t___construct(Variant v_filename, Variant v_open_mode // = NAMSTR(s_sys_ss3bf6014b, "r") , Variant v_use_include_path // = false , Variant v_context // = null ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::__construct); x_hphp_splfileobject___construct(GET_THIS_TYPED(SplFileObject), toString(v_filename), toString(v_open_mode), toBoolean(v_use_include_path), v_context); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 410 */ Variant c_SplFileObject::t_current() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::current); return x_hphp_splfileobject_current(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 422 */ bool c_SplFileObject::t_eof() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::eof); return x_hphp_splfileobject_eof(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 434 */ bool c_SplFileObject::t_fflush() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fflush); return x_hphp_splfileobject_fflush(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 452 */ String c_SplFileObject::t_fgetc() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fgetc); return x_hphp_splfileobject_fgetc(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 482 */ Variant c_SplFileObject::t_fgetcsv(CVarRef v_delimiter // = NAMVAR(s_sys_svs71ed8566, ",") , CVarRef v_enclosure // = NAMVAR(s_sys_svs4f157ea2, "\"") , CVarRef v_escape // = NAMVAR(s_sys_svs501eef9b, "\\") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fgetcsv); return x_hphp_splfileobject_fgetcsv(GET_THIS_TYPED(SplFileObject), toString(v_delimiter), toString(v_enclosure), toString(v_escape)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 497 */ String c_SplFileObject::t_fgets() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fgets); return x_hphp_splfileobject_fgets(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 517 */ String c_SplFileObject::t_fgetss(CVarRef v_allowable_tags) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fgetss); return x_hphp_splfileobject_fgetss(GET_THIS_TYPED(SplFileObject), toString(v_allowable_tags)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 537 */ bool c_SplFileObject::t_flock(CVarRef v_operation, VRefParam rv_wouldblock) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::flock); Variant &v_wouldblock ATTRIBUTE_UNUSED = rv_wouldblock; return x_hphp_splfileobject_flock(GET_THIS_TYPED(SplFileObject), ref(v_wouldblock)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 555 */ int64 c_SplFileObject::t_fpassthru() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fpassthru); return x_hphp_splfileobject_fpassthru(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 579 */ Variant c_SplFileObject::t_fscanf(int num_args, CVarRef v_format, Array args /* = Array() */) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fscanf); int64 v_argc = 0; Array v_argv; { int64 tmp0((num_args)); v_argc = tmp0; } { const Array &tmp0((func_get_args(num_args, Array(ArrayInit(1, ArrayInit::vectorInit).set(v_format).create()),args))); v_argv = tmp0; } return x_hphp_splfileobject_fscanf(v_argc, GET_THIS_TYPED(SplFileObject), toString(v_format), VarNR(v_argv)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 607 */ int64 c_SplFileObject::t_fseek(CVarRef v_offset, CVarRef v_whence) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fseek); return x_hphp_splfileobject_fseek(GET_THIS_TYPED(SplFileObject), toInt64(v_offset), toInt64(v_whence)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 621 */ Variant c_SplFileObject::t_fstat() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fstat); return x_hphp_splfileobject_fstat(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 635 */ int64 c_SplFileObject::t_ftell() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::ftell); return x_hphp_splfileobject_ftell(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 655 */ bool c_SplFileObject::t_ftruncate(CVarRef v_size) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::ftruncate); return x_hphp_splfileobject_ftruncate(GET_THIS_TYPED(SplFileObject), toInt64(v_size)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 673 */ int64 c_SplFileObject::t_fwrite(CVarRef v_str, CVarRef v_length) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::fwrite); return x_hphp_splfileobject_fwrite(GET_THIS_TYPED(SplFileObject), toString(v_str), toInt64(v_length)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 685 */ Variant c_SplFileObject::t_getchildren() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::getChildren); return null; } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 699 */ Variant c_SplFileObject::t_getcsvcontrol() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::getCsvControl); return x_hphp_splfileobject_getcvscontrol(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 711 */ int64 c_SplFileObject::t_getflags() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::getFlags); return x_hphp_splfileobject_getflags(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 725 */ int64 c_SplFileObject::t_getmaxlinelen() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::getMaxLineLen); return x_hphp_splfileobject_getmaxlinelen(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 738 */ bool c_SplFileObject::t_haschildren() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::hasChildren); return false; } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 754 */ int64 c_SplFileObject::t_key() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::key); return x_hphp_splfileobject_key(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 766 */ void c_SplFileObject::t_next() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::next); x_hphp_splfileobject_next(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 778 */ void c_SplFileObject::t_rewind() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::rewind); x_hphp_splfileobject_rewind(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 792 */ void c_SplFileObject::t_seek(CVarRef v_line_pos) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::seek); x_hphp_splfileobject_seek(GET_THIS_TYPED(SplFileObject), toInt64(v_line_pos)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 809 */ void c_SplFileObject::t_setcsvcontrol(CVarRef v_delimiter // = NAMVAR(s_sys_svs71ed8566, ",") , CVarRef v_enclosure // = NAMVAR(s_sys_svs4f157ea2, "\"") , CVarRef v_escape // = NAMVAR(s_sys_svs501eef9b, "\\") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::setCsvControl); x_hphp_splfileobject_setcsvcontrol(GET_THIS_TYPED(SplFileObject), toString(v_delimiter), toString(v_enclosure), toString(v_escape)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 825 */ void c_SplFileObject::t_setflags(CVarRef v_flags) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::setFlags); x_hphp_splfileobject_setflags(GET_THIS_TYPED(SplFileObject), toInt64(v_flags)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 840 */ void c_SplFileObject::t_setmaxlinelen(CVarRef v_max_len) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::setMaxLineLen); x_hphp_splfileobject_setmaxlinelen(GET_THIS_TYPED(SplFileObject), toInt64(v_max_len)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 852 */ bool c_SplFileObject::t_valid() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileObject, SplFileObject::valid); return x_hphp_splfileobject_valid(GET_THIS_TYPED(SplFileObject)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 11 */ IMPLEMENT_CLASS_NO_DEFAULT_SWEEP(SplFileInfo) extern const InstanceOfInfo cw_SplFileInfo$$instanceof_table[] = { {0x4682C3C3,1,"SplFileInfo",&cw_SplFileInfo}, }; const int cw_SplFileInfo$$instanceof_index[] = { 1, -1,0, }; extern const CallInfo ci_SplFileInfo$$getfileinfo = { (void*)&c_SplFileInfo::i_getfileinfo, (void*)&c_SplFileInfo::ifa_getfileinfo, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getsize = { (void*)&c_SplFileInfo::i_getsize, (void*)&c_SplFileInfo::ifa_getsize, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$isdir = { (void*)&c_SplFileInfo::i_isdir, (void*)&c_SplFileInfo::ifa_isdir, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getbasename = { (void*)&c_SplFileInfo::i_getbasename, (void*)&c_SplFileInfo::ifa_getbasename, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$gettype = { (void*)&c_SplFileInfo::i_gettype, (void*)&c_SplFileInfo::ifa_gettype, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getpathinfo = { (void*)&c_SplFileInfo::i_getpathinfo, (void*)&c_SplFileInfo::ifa_getpathinfo, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$openfile = { (void*)&c_SplFileInfo::i_openfile, (void*)&c_SplFileInfo::ifa_openfile, 3, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$__tostring = { (void*)&c_SplFileInfo::i___tostring, (void*)&c_SplFileInfo::ifa___tostring, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getpath = { (void*)&c_SplFileInfo::i_getpath, (void*)&c_SplFileInfo::ifa_getpath, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$iswritable = { (void*)&c_SplFileInfo::i_iswritable, (void*)&c_SplFileInfo::ifa_iswritable, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$isreadable = { (void*)&c_SplFileInfo::i_isreadable, (void*)&c_SplFileInfo::ifa_isreadable, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getmtime = { (void*)&c_SplFileInfo::i_getmtime, (void*)&c_SplFileInfo::ifa_getmtime, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getinode = { (void*)&c_SplFileInfo::i_getinode, (void*)&c_SplFileInfo::ifa_getinode, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$isfile = { (void*)&c_SplFileInfo::i_isfile, (void*)&c_SplFileInfo::ifa_isfile, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$setinfoclass = { (void*)&c_SplFileInfo::i_setinfoclass, (void*)&c_SplFileInfo::ifa_setinfoclass, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getfilename = { (void*)&c_SplFileInfo::i_getfilename, (void*)&c_SplFileInfo::ifa_getfilename, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getgroup = { (void*)&c_SplFileInfo::i_getgroup, (void*)&c_SplFileInfo::ifa_getgroup, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getrealpath = { (void*)&c_SplFileInfo::i_getrealpath, (void*)&c_SplFileInfo::ifa_getrealpath, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getctime = { (void*)&c_SplFileInfo::i_getctime, (void*)&c_SplFileInfo::ifa_getctime, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getowner = { (void*)&c_SplFileInfo::i_getowner, (void*)&c_SplFileInfo::ifa_getowner, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getlinktarget = { (void*)&c_SplFileInfo::i_getlinktarget, (void*)&c_SplFileInfo::ifa_getlinktarget, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$__construct = { (void*)&c_SplFileInfo::i___construct, (void*)&c_SplFileInfo::ifa___construct, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getpathname = { (void*)&c_SplFileInfo::i_getpathname, (void*)&c_SplFileInfo::ifa_getpathname, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getatime = { (void*)&c_SplFileInfo::i_getatime, (void*)&c_SplFileInfo::ifa_getatime, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$getperms = { (void*)&c_SplFileInfo::i_getperms, (void*)&c_SplFileInfo::ifa_getperms, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$islink = { (void*)&c_SplFileInfo::i_islink, (void*)&c_SplFileInfo::ifa_islink, 0, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$setfileclass = { (void*)&c_SplFileInfo::i_setfileclass, (void*)&c_SplFileInfo::ifa_setfileclass, 1, 4, 0x0000000000000000L}; extern const CallInfo ci_SplFileInfo$$isexecutable = { (void*)&c_SplFileInfo::i_isexecutable, (void*)&c_SplFileInfo::ifa_isexecutable, 0, 4, 0x0000000000000000L}; Variant c_SplFileInfo::i___construct(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa___construct); } Variant c_SplFileInfo::i_getpath(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getpath); } Variant c_SplFileInfo::i_getfilename(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getfilename); } Variant c_SplFileInfo::i_getfileinfo(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getfileinfo); } Variant c_SplFileInfo::i_getbasename(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getbasename); } Variant c_SplFileInfo::i_getpathname(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getpathname); } Variant c_SplFileInfo::i_getpathinfo(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getpathinfo); } Variant c_SplFileInfo::i_getperms(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getperms); } Variant c_SplFileInfo::i_getinode(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getinode); } Variant c_SplFileInfo::i_getsize(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getsize); } Variant c_SplFileInfo::i_getowner(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getowner); } Variant c_SplFileInfo::i_getgroup(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getgroup); } Variant c_SplFileInfo::i_getatime(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getatime); } Variant c_SplFileInfo::i_getmtime(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getmtime); } Variant c_SplFileInfo::i_getctime(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getctime); } Variant c_SplFileInfo::i_gettype(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_gettype); } Variant c_SplFileInfo::i_iswritable(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_iswritable); } Variant c_SplFileInfo::i_isreadable(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_isreadable); } Variant c_SplFileInfo::i_isexecutable(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_isexecutable); } Variant c_SplFileInfo::i_isfile(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_isfile); } Variant c_SplFileInfo::i_isdir(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_isdir); } Variant c_SplFileInfo::i_islink(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_islink); } Variant c_SplFileInfo::i_getlinktarget(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getlinktarget); } Variant c_SplFileInfo::i_getrealpath(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_getrealpath); } Variant c_SplFileInfo::i___tostring(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa___tostring); } Variant c_SplFileInfo::i_openfile(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_openfile); } Variant c_SplFileInfo::i_setfileclass(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_setfileclass); } Variant c_SplFileInfo::i_setinfoclass(MethodCallPackage &mcp, CArrRef params) { return invoke_meth_few_handler(mcp, params, &ifa_setinfoclass); } Variant NEVER_INLINE c_SplFileInfo::ifa___construct(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa___construct, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count != 1)) return throw_wrong_arguments("SplFileInfo::__construct", count, 1, 1, 2); CVarRef arg0(a0); return (self->t___construct(arg0), null); } Variant NEVER_INLINE c_SplFileInfo::ifa_getpath(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getpath, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getPath", 0, 1); return (self->t_getpath()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getfilename(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getfilename, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getFilename", 0, 1); return (self->t_getfilename()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getfileinfo(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getfileinfo, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 1)) return throw_toomany_arguments("SplFileInfo::getFileInfo", 1, 1); if (count <= 0) return (self->t_getfileinfo()); CVarRef arg0(a0); return (self->t_getfileinfo(arg0)); } Variant NEVER_INLINE c_SplFileInfo::ifa_getbasename(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getbasename, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 1)) return throw_toomany_arguments("SplFileInfo::getBasename", 1, 1); if (count <= 0) return (self->t_getbasename()); CVarRef arg0(a0); return (self->t_getbasename(arg0)); } Variant NEVER_INLINE c_SplFileInfo::ifa_getpathname(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getpathname, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getPathname", 0, 1); return (self->t_getpathname()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getpathinfo(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getpathinfo, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 1)) return throw_toomany_arguments("SplFileInfo::getPathInfo", 1, 1); if (count <= 0) return (self->t_getpathinfo()); CVarRef arg0(a0); return (self->t_getpathinfo(arg0)); } Variant NEVER_INLINE c_SplFileInfo::ifa_getperms(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getperms, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getPerms", 0, 1); return (self->t_getperms()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getinode(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getinode, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getInode", 0, 1); return (self->t_getinode()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getsize(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getsize, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getSize", 0, 1); return (self->t_getsize()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getowner(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getowner, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getOwner", 0, 1); return (self->t_getowner()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getgroup(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getgroup, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getGroup", 0, 1); return (self->t_getgroup()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getatime(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getatime, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getATime", 0, 1); return (self->t_getatime()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getmtime(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getmtime, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getMTime", 0, 1); return (self->t_getmtime()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getctime(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getctime, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getCTime", 0, 1); return (self->t_getctime()); } Variant NEVER_INLINE c_SplFileInfo::ifa_gettype(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_gettype, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getType", 0, 1); return (self->t_gettype()); } Variant NEVER_INLINE c_SplFileInfo::ifa_iswritable(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_iswritable, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isWritable", 0, 1); return (self->t_iswritable()); } Variant NEVER_INLINE c_SplFileInfo::ifa_isreadable(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_isreadable, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isReadable", 0, 1); return (self->t_isreadable()); } Variant NEVER_INLINE c_SplFileInfo::ifa_isexecutable(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_isexecutable, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isExecutable", 0, 1); return (self->t_isexecutable()); } Variant NEVER_INLINE c_SplFileInfo::ifa_isfile(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_isfile, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isFile", 0, 1); return (self->t_isfile()); } Variant NEVER_INLINE c_SplFileInfo::ifa_isdir(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_isdir, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isDir", 0, 1); return (self->t_isdir()); } Variant NEVER_INLINE c_SplFileInfo::ifa_islink(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_islink, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::isLink", 0, 1); return (self->t_islink()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getlinktarget(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getlinktarget, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getLinkTarget", 0, 1); return (self->t_getlinktarget()); } Variant NEVER_INLINE c_SplFileInfo::ifa_getrealpath(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_getrealpath, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::getRealPath", 0, 1); return (self->t_getrealpath()); } Variant NEVER_INLINE c_SplFileInfo::ifa___tostring(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa___tostring, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 0)) return throw_toomany_arguments("SplFileInfo::__toString", 0, 1); return (self->t___tostring()); } Variant NEVER_INLINE c_SplFileInfo::ifa_openfile(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_openfile, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 3)) return throw_toomany_arguments("SplFileInfo::openFile", 3, 1); if (count <= 0) return (self->t_openfile()); CVarRef arg0(a0); if (count <= 1) return (self->t_openfile(arg0)); CVarRef arg1(a1); if (count <= 2) return (self->t_openfile(arg0, arg1)); CVarRef arg2(a2); return (self->t_openfile(arg0, arg1, arg2)); } Variant NEVER_INLINE c_SplFileInfo::ifa_setfileclass(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_setfileclass, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 1)) return throw_toomany_arguments("SplFileInfo::setFileClass", 1, 1); if (count <= 0) return (self->t_setfileclass(), null); CVarRef arg0(a0); return (self->t_setfileclass(arg0), null); } Variant NEVER_INLINE c_SplFileInfo::ifa_setinfoclass(MethodCallPackage &mcp, int count, INVOKE_FEW_ARGS_IMPL_ARGS) { if (UNLIKELY(mcp.obj == 0)) { return ObjectData::ifa_dummy(mcp, count, INVOKE_FEW_ARGS_PASS_ARGS, ifa_setinfoclass, coo_SplFileInfo); } c_SplFileInfo *self ATTRIBUTE_UNUSED (static_cast<c_SplFileInfo*>(mcp.obj)); if (UNLIKELY(count > 1)) return throw_toomany_arguments("SplFileInfo::setInfoClass", 1, 1); if (count <= 0) return (self->t_setinfoclass(), null); CVarRef arg0(a0); return (self->t_setinfoclass(arg0), null); } extern const MethodCallInfoTable cw_SplFileInfo$$call_info_table[] = { { 0x3C356D02, 1, 8, "getInode", &ci_SplFileInfo$$getinode }, { 0x033EAF43, 0, 8, "getGroup", &ci_SplFileInfo$$getgroup }, { 0x3A0B6703, 1, 11, "getRealPath", &ci_SplFileInfo$$getrealpath }, { 0x0DE985C7, 1, 5, "isDir", &ci_SplFileInfo$$isdir }, { 0x51881149, 1, 6, "isLink", &ci_SplFileInfo$$islink }, { 0x1D5001CD, 0, 11, "getPathname", &ci_SplFileInfo$$getpathname }, { 0x7BDF404D, 1, 10, "__toString", &ci_SplFileInfo$$__tostring }, { 0x05BD2811, 1, 7, "getSize", &ci_SplFileInfo$$getsize }, { 0x7AD99D16, 0, 10, "isReadable", &ci_SplFileInfo$$isreadable }, { 0x618BDB56, 1, 12, "setFileClass", &ci_SplFileInfo$$setfileclass }, { 0x6DE2DC98, 0, 11, "getFileInfo", &ci_SplFileInfo$$getfileinfo }, { 0x17334E18, 1, 11, "getBasename", &ci_SplFileInfo$$getbasename }, { 0x486CB9DC, 0, 11, "getFilename", &ci_SplFileInfo$$getfilename }, { 0x6073C5DC, 1, 8, "getMTime", &ci_SplFileInfo$$getmtime }, { 0x69440E29, 1, 12, "setInfoClass", &ci_SplFileInfo$$setinfoclass }, { 0x61BFFA6B, 1, 7, "getPath", &ci_SplFileInfo$$getpath }, { 0x3A40C6ED, 1, 11, "__construct", &ci_SplFileInfo$$__construct }, { 0x15CCBAB0, 0, 8, "getATime", &ci_SplFileInfo$$getatime }, { 0x77C62730, 1, 8, "openFile", &ci_SplFileInfo$$openfile }, { 0x31034E71, 1, 8, "getPerms", &ci_SplFileInfo$$getperms }, { 0x367202F6, 0, 8, "getOwner", &ci_SplFileInfo$$getowner }, { 0x3D45FCF6, 1, 13, "getLinkTarget", &ci_SplFileInfo$$getlinktarget }, { 0x193A28B7, 1, 12, "isExecutable", &ci_SplFileInfo$$isexecutable }, { 0x23FDDFFB, 1, 11, "getPathInfo", &ci_SplFileInfo$$getpathinfo }, { 0x2FFBBC7C, 0, 7, "getType", &ci_SplFileInfo$$gettype }, { 0x709E0E7C, 0, 10, "isWritable", &ci_SplFileInfo$$iswritable }, { 0x438706FC, 1, 6, "isFile", &ci_SplFileInfo$$isfile }, { 0x12673AFF, 1, 8, "getCTime", &ci_SplFileInfo$$getctime }, }; extern const int cw_SplFileInfo$$call_info_index[] = { 63, -1,-1,0,1,-1,-1,-1,3, -1,4,-1,-1,-1,5,-1,-1, -1,7,-1,-1,-1,-1,8,-1, 10,-1,-1,-1,12,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,14,-1,15,-1,16,-1,-1, 17,19,-1,-1,-1,-1,20,22, -1,-1,-1,23,24,-1,-1,27, }; c_SplFileInfo *c_SplFileInfo::create(CVarRef v_file_name) { CountableHelper h(this); init(); t___construct(v_file_name); return this; } extern const MethodCallInfoTable cw_SplFileInfo$$call_info_table[]; extern const int cw_SplFileInfo$$call_info_index[]; extern const InstanceOfInfo cw_SplFileInfo$$instanceof_table[]; extern const int cw_SplFileInfo$$instanceof_index[]; const ObjectStaticCallbacks cw_SplFileInfo = { (ObjectData*(*)(ObjectData*))coo_SplFileInfo, cw_SplFileInfo$$call_info_table,cw_SplFileInfo$$call_info_index, cw_SplFileInfo$$instanceof_table,cw_SplFileInfo$$instanceof_index, &c_SplFileInfo::s_class_name, &c_SplFileInfo::os_prop_table,&ci_SplFileInfo$$__construct,0,0,0x0, &c_SplFileInfo::s_cls }; /* SRC: classes/splfile.php line 14 */ void c_SplFileInfo::t___construct(Variant v_file_name) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::__construct); x_hphp_splfileinfo___construct(GET_THIS_TYPED(SplFileInfo), toString(v_file_name)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 27 */ String c_SplFileInfo::t_getpath() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getPath); return x_hphp_splfileinfo_getpath(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 39 */ String c_SplFileInfo::t_getfilename() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getFilename); return x_hphp_splfileinfo_getfilename(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 53 */ Object c_SplFileInfo::t_getfileinfo(CVarRef v_class_name // = NAMVAR(s_sys_svs00000000, "") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getFileInfo); return x_hphp_splfileinfo_getfileinfo(GET_THIS_TYPED(SplFileInfo), toString(v_class_name)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 68 */ String c_SplFileInfo::t_getbasename(CVarRef v_suffix // = NAMVAR(s_sys_svs00000000, "") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getBasename); return x_hphp_splfileinfo_getbasename(GET_THIS_TYPED(SplFileInfo), toString(v_suffix)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 80 */ String c_SplFileInfo::t_getpathname() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getPathname); return x_hphp_splfileinfo_getpathname(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 95 */ Object c_SplFileInfo::t_getpathinfo(CVarRef v_class_name // = NAMVAR(s_sys_svs00000000, "") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getPathInfo); return x_hphp_splfileinfo_getpathinfo(GET_THIS_TYPED(SplFileInfo), toString(v_class_name)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 107 */ int64 c_SplFileInfo::t_getperms() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getPerms); return x_hphp_splfileinfo_getperms(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 119 */ int64 c_SplFileInfo::t_getinode() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getInode); return x_hphp_splfileinfo_getinode(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 131 */ int64 c_SplFileInfo::t_getsize() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getSize); return x_hphp_splfileinfo_getsize(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 143 */ int64 c_SplFileInfo::t_getowner() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getOwner); return x_hphp_splfileinfo_getowner(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 155 */ int64 c_SplFileInfo::t_getgroup() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getGroup); return x_hphp_splfileinfo_getgroup(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 167 */ int64 c_SplFileInfo::t_getatime() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getATime); return x_hphp_splfileinfo_getatime(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 181 */ int64 c_SplFileInfo::t_getmtime() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getMTime); return x_hphp_splfileinfo_getmtime(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 194 */ int64 c_SplFileInfo::t_getctime() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getCTime); return x_hphp_splfileinfo_getctime(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 207 */ String c_SplFileInfo::t_gettype() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getType); return x_hphp_splfileinfo_gettype(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 219 */ bool c_SplFileInfo::t_iswritable() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isWritable); return x_hphp_splfileinfo_iswritable(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 231 */ bool c_SplFileInfo::t_isreadable() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isReadable); return x_hphp_splfileinfo_isreadable(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 243 */ bool c_SplFileInfo::t_isexecutable() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isExecutable); return x_hphp_splfileinfo_isexecutable(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 257 */ bool c_SplFileInfo::t_isfile() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isFile); return x_hphp_splfileinfo_isfile(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 269 */ bool c_SplFileInfo::t_isdir() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isDir); return x_hphp_splfileinfo_isdir(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 282 */ bool c_SplFileInfo::t_islink() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::isLink); return x_hphp_splfileinfo_islink(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 297 */ String c_SplFileInfo::t_getlinktarget() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getLinkTarget); return x_hphp_splfileinfo_getlinktarget(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 310 */ Variant c_SplFileInfo::t_getrealpath() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::getRealPath); return x_hphp_splfileinfo_getrealpath(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 314 */ String c_SplFileInfo::t___tostring() { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::__toString); return x_hphp_splfileinfo___tostring(GET_THIS_TYPED(SplFileInfo)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 338 */ Object c_SplFileInfo::t_openfile(CVarRef v_mode // = NAMVAR(s_sys_svs3bf6014b, "r") , CVarRef v_use_include_path // = false_varNR , CVarRef v_context // = null_variant ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::openFile); return x_hphp_splfileinfo_openfile(GET_THIS_TYPED(SplFileInfo), toString(v_mode), toBoolean(v_use_include_path), v_context); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 356 */ void c_SplFileInfo::t_setfileclass(CVarRef v_class_name // = NAMVAR(s_sys_svs3d15f0b0, "SplFileObject") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::setFileClass); x_hphp_splfileinfo_setfileclass(GET_THIS_TYPED(SplFileInfo), toString(v_class_name)); } namespace hphp_impl_splitter {} /* SRC: classes/splfile.php line 372 */ void c_SplFileInfo::t_setinfoclass(CVarRef v_class_name // = NAMVAR(s_sys_svs15a7ef11, "SplFileInfo") ) { INSTANCE_METHOD_INJECTION_BUILTIN(SplFileInfo, SplFileInfo::setInfoClass); x_hphp_splfileinfo_setinfoclass(GET_THIS_TYPED(SplFileInfo), toString(v_class_name)); } namespace hphp_impl_splitter {} ObjectData *coo_SplFileObject() { return NEWOBJ(c_SplFileObject)(); } ObjectData *coo_SplFileInfo() { return NEWOBJ(c_SplFileInfo)(); } // Class tables static const int64 cpt_static_inits[] = { (int64)&null_variant, (int64)&NAMVAR(s_sys_svi90d5f98c, int64_t(2)), (int64)&NAMVAR(s_sys_svi4d7e8e12, int64_t(6)), (int64)&NAMVAR(s_sys_svib794f8ce, int64_t(1)), (int64)&NAMVAR(s_sys_svic3578135, int64_t(8)), }; static const ClassPropTableEntry cpt_table_entries[] = { {0x64046A18,0,0,13,65,-1,GET_PROPERTY_OFFSET(c_SplFileInfo, m_rsrc),&NAMSTR(s_sys_ss235be22e, "\000SplFileInfo\000rsrc") }, {0x1F4FAED8,1,1,0,100,10,0,&NAMSTR(s_sys_ss1f4faed8, "READ_AHEAD") }, {0x1C6C4A31,2,2,0,100,10,0,&NAMSTR(s_sys_ss1c6c4a31, "SKIP_EMPTY") }, {0x3BFDC8A6,-2,3,0,36,10,0,&NAMSTR(s_sys_ss3bfdc8a6, "DROP_NEW_LINE") }, {0x779FFACE,0,4,0,100,10,0,&NAMSTR(s_sys_ss779fface, "READ_CSV") }, }; static const int cpt_hash_entries[] = { // SplFileInfo hash 0,-1,-1,-1,-1,-1,-1,-1, // SplFileInfo lists 0,-1, -1, -1, // SplFileObject hash -1,2,-1,-1,-1,-1,1,0, // SplFileObject lists -1, -1, -1, }; const ClassPropTable c_SplFileInfo::os_prop_table = { 7,0,-1,-1,-1,-1,10,0, cpt_hash_entries+0,0,cpt_table_entries+0,cpt_static_inits }; const ClassPropTable c_SplFileObject::os_prop_table = { -1,-1,-1,-1,7,2,1,0, cpt_hash_entries+20,&c_SplFileInfo::os_prop_table,cpt_table_entries+1,cpt_static_inits }; /////////////////////////////////////////////////////////////////////////////// }
[ "mikesjett@gmail.com" ]
mikesjett@gmail.com
3547ef19a6a1884aabb3f9691b123f2b09892ca9
6db9478ab57690420b2aa98b450d346f7a9f3b7d
/z_unclassified/11729.cpp
1e3f2522b11a33f6ef49ab9a36df74457cd075da
[]
no_license
siosio34/AlgorithmStudy
d23266e0d4576a3aab123aee7b571021ec619009
b5626a0e4eb14f9553fe48aacacb1696a927c740
refs/heads/master
2020-03-19T09:15:13.167353
2019-05-22T13:50:41
2019-05-22T13:50:41
136,272,154
0
0
null
null
null
null
UTF-8
C++
false
false
620
cpp
#include <iostream> #include <stdio.h> using namespace std; // 한번에 한개의 원탑만 옮기기 // 쌓아놓은 원판은 항상 위의것이 아래것보다 작아야됨. void solve(int number, int x, int y) { if(number == 0) { return; } // z 는 6-x-y; // n-1 개의원판을 x부터 z까지 옮겨놓은다음에 solve(number - 1, x, 6 - x - y); printf("%d %d\n", x, y); // n번째원판을 y로 옮기고 // 나머지 n-1 개의원판을 z에서 y로 옮겨준다. solve(number - 1, 6 - x - y,y); } int main() { int n; cin >> n; cout << (1 << n) - 1 << endl; solve(n, 1, 3); return 0; }
[ "siosio34@nate.com" ]
siosio34@nate.com
4515d28d78e6405841b78af4b98137ce06086568
bb2d45152b6fc2ebe9d1a264175369f75fb5d024
/Arcane/src/Arcane/Vendor/renderdoc-1.x/renderdoc/serialise/lz4io.h
4faadef42f6261f8184d29d1287ab82459e15128
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Ershany/Arcane-Engine
b719930e7538dcb99185fa31e0255fd2d2b2383b
94ae49d04359bb79916f61fe7c2130939f88f49d
refs/heads/master
2023-07-27T04:38:23.753293
2023-07-23T22:13:48
2023-07-23T22:13:48
66,559,567
492
42
MIT
2023-07-15T12:33:51
2016-08-25T13:20:39
C++
UTF-8
C++
false
false
2,069
h
/****************************************************************************** * The MIT License (MIT) * * Copyright (c) 2019-2022 Baldur Karlsson * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ #pragma once #include "lz4/lz4.h" #include "streamio.h" class LZ4Compressor : public Compressor { public: LZ4Compressor(StreamWriter *write, Ownership own); ~LZ4Compressor(); bool Write(const void *data, uint64_t numBytes); bool Finish(); private: bool FlushPage0(); byte *m_Page[2]; byte *m_CompressBuffer; uint64_t m_PageOffset; LZ4_stream_t *m_LZ4Comp; }; class LZ4Decompressor : public Decompressor { public: LZ4Decompressor(StreamReader *read, Ownership own); ~LZ4Decompressor(); bool Recompress(Compressor *comp); bool Read(void *data, uint64_t numBytes); private: bool FillPage0(); byte *m_Page[2]; byte *m_CompressBuffer; uint64_t m_PageOffset; uint64_t m_PageLength; LZ4_streamDecode_t *m_LZ4Decomp; };
[ "bradyjessup@hotmail.com" ]
bradyjessup@hotmail.com
ed30efcc128168e4265082ad5cb762ca8e70cbe9
8efe005ac9cbc202ef1db530954f142933a4b184
/0721/thread/produce_thread.cc
25be85de6587fed5a159d432dae8dedacc935cb7
[]
no_license
dasima/WD
e58ec753003d28df5420942ed14f090cd9456ecb
f7f6f3dd3ea8faef982cb72279021118c91935f8
refs/heads/master
2021-01-19T03:18:35.707357
2014-08-27T01:34:04
2014-08-27T01:34:04
21,316,067
1
0
null
null
null
null
UTF-8
C++
false
false
241
cc
#include "thread.h" #include "produce_thread.h" using namespace std; void ProduceThread::run() { int data; while(1) { data = rand() % 100; cout << "produce a data -----" << data << endl; sleep(1); } }
[ "zhahw136@126.com" ]
zhahw136@126.com
460450b014887dc9214c4556786a2e06a60c136c
e37d6479533fa5fbb6a8646fee5a2faa22d4fdb2
/src/saiga/sound/OpusCodec.h
a667cdaab052fe70049639b6191c92017cf9f954
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ElectricRobot/saiga
4996b6327f4472eb3feff3000b19c6882125da68
4987074847aabd025278168ea72ca8a991811c42
refs/heads/master
2020-04-11T03:41:01.515890
2018-12-12T09:25:16
2018-12-12T09:25:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
769
h
/** * Copyright (c) 2017 Darius Rückert * Licensed under the MIT License. * See LICENSE file for more information. */ // (c) Seth Heeren 2013 // // Based on src/opus_demo.c in opus-1.0.2 // License see http://www.opus-codec.org/license/ #pragma once #include <iosfwd> #include <memory> #include <stdexcept> #include <vector> namespace Saiga { struct OpusErrorException : public virtual std::exception { OpusErrorException(int code) : code(code) {} const char* what(); private: const int code; }; struct COpusCodec { COpusCodec(int32_t sampling_rate, int channels); ~COpusCodec(); std::vector<unsigned char> decode_frame(std::istream& fin); private: struct Impl; std::unique_ptr<Impl> _pimpl; }; } // namespace Saiga
[ "darius.rueckert@fau.de" ]
darius.rueckert@fau.de
1700a2a2d808f2b6ba68ab230d84645c2f0be4a1
8d63452d9dbc650884966b07a5652975f1e71961
/dlls/hl2mp_dll/hl2mp_gameinterface.cpp
d511c5fbfc77406feb66e03399a53e6fcb1b335e
[]
no_license
0TheSpy/hl2sdk
d2656cb99304ca8b7be7b67631e45f416539f02c
8b2833d5909f27219d90000260887a3aeb32d485
refs/heads/master
2023-03-15T20:28:37.485807
2012-05-30T01:09:21
2012-05-30T01:09:21
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,686
cpp
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // //=============================================================================// #include "cbase.h" #include "gameinterface.h" #include "mapentities.h" #include "hl2mp_gameinterface.h" #include "utllinkedlist.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" CUtlLinkedList<CMapEntityRef, unsigned short> g_MapEntityRefs; void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const { minplayers = defaultMaxPlayers = 2; maxplayers = 16; } // -------------------------------------------------------------------------------------------- // // Mod-specific CServerGameDLL implementation. // -------------------------------------------------------------------------------------------- // class CHL2MPMapLoadEntityFilter : public IMapEntityFilter { public: virtual bool ShouldCreateEntity( const char *pClassname ) { // During map load, create all the entities. return true; } virtual CBaseEntity* CreateNextEntity( const char *pClassname ) { CBaseEntity *pRet = CreateEntityByName( pClassname ); CMapEntityRef ref; ref.m_iEdict = -1; ref.m_iSerialNumber = -1; if ( pRet ) { ref.m_iEdict = pRet->entindex(); if ( pRet->edict() ) ref.m_iSerialNumber = pRet->edict()->m_NetworkSerialNumber; } g_MapEntityRefs.AddToTail( ref ); return pRet; } }; void CServerGameDLL::LevelInit_ParseAllEntities( const char *pMapEntities ) { g_MapEntityRefs.Purge(); CHL2MPMapLoadEntityFilter filter; MapEntity_ParseAllEntities( pMapEntities, &filter ); }
[ "ds@alliedmods.net" ]
ds@alliedmods.net
cdcef05710509ad2232af0833529218dc0e55d86
9bbab57e96b2130f009db77bd925acdf6e721f7e
/Day-14/01-Functional_templates.cpp
5f786f31e74755d53af426efbf6d4ccbf27b9146
[]
no_license
sidhu421/Cpp_Course
abe7b9a3eec014d21525e68749891d952368b5c0
e50ad1d4a159dab583880c49e6d7fb9923e43125
refs/heads/main
2023-06-19T06:03:36.264577
2021-07-09T13:44:15
2021-07-09T13:44:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
284
cpp
#include<iostream> using namespace std; template <class T> void display(T a){ cout << a << endl; } // void display(double a){ // cout << a << endl; // } int main(){ display<int>(10); display<double>(12.36); display<string>("Hello everyone"); return 0; }
[ "satyambhalla17@gmail.com" ]
satyambhalla17@gmail.com
b622dfc6a55a126f63944bf5ed0b306dc1957cec
88b81f24bafabd8595df52f6a929b5df32b4fd3a
/sources/Renderer/OpenGL/Shader/GLShaderUniform.h
4850a17adf046a8f1779f68ff08b951f88de53dd
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
whztt07/LLGL
18fb2d74edc1d5dccdf76c5ba3cd9b95ebceb70f
c238ca4558209888c72b10a88d09a3b532eba06d
refs/heads/master
2020-03-19T01:09:48.667445
2018-04-09T13:33:00
2018-04-09T13:33:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,647
h
/* * GLShaderUniform.h * * This file is part of the "LLGL" project (Copyright (c) 2015 by Lukas Hermanns) * See "LICENSE.txt" for license information. */ #ifndef LLGL_GL_SHADER_UNIFORM_H #define LLGL_GL_SHADER_UNIFORM_H #include <LLGL/ShaderUniform.h> #include "../OpenGL.h" namespace LLGL { class GLShaderUniform : public ShaderUniform { public: GLShaderUniform(GLuint program); void SetUniform(int location, const int value) override; void SetUniform(int location, const Gs::Vector2i& value) override; void SetUniform(int location, const Gs::Vector3i& value) override; void SetUniform(int location, const Gs::Vector4i& value) override; void SetUniform(int location, const float value) override; void SetUniform(int location, const Gs::Vector2f& value) override; void SetUniform(int location, const Gs::Vector3f& value) override; void SetUniform(int location, const Gs::Vector4f& value) override; void SetUniform(int location, const Gs::Matrix2f& value) override; void SetUniform(int location, const Gs::Matrix3f& value) override; void SetUniform(int location, const Gs::Matrix4f& value) override; void SetUniform(const std::string& name, const int value) override; void SetUniform(const std::string& name, const Gs::Vector2i& value) override; void SetUniform(const std::string& name, const Gs::Vector3i& value) override; void SetUniform(const std::string& name, const Gs::Vector4i& value) override; void SetUniform(const std::string& name, const float value) override; void SetUniform(const std::string& name, const Gs::Vector2f& value) override; void SetUniform(const std::string& name, const Gs::Vector3f& value) override; void SetUniform(const std::string& name, const Gs::Vector4f& value) override; void SetUniform(const std::string& name, const Gs::Matrix2f& value) override; void SetUniform(const std::string& name, const Gs::Matrix3f& value) override; void SetUniform(const std::string& name, const Gs::Matrix4f& value) override; void SetUniformArray(int location, const int* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector2i* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector3i* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector4i* value, std::size_t count) override; void SetUniformArray(int location, const float* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector2f* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector3f* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Vector4f* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Matrix2f* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Matrix3f* value, std::size_t count) override; void SetUniformArray(int location, const Gs::Matrix4f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const int* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector2i* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector3i* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector4i* value, std::size_t count) override; void SetUniformArray(const std::string& name, const float* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector2f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector3f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Vector4f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Matrix2f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Matrix3f* value, std::size_t count) override; void SetUniformArray(const std::string& name, const Gs::Matrix4f* value, std::size_t count) override; private: GLint GetLocation(const std::string& name) const; GLuint program_ = 0; }; } // /namespace LLGL #endif // ================================================================================
[ "lukas.hermanns90@gmail.com" ]
lukas.hermanns90@gmail.com
8154fab43eaf870fe45589d72e4e219f66624d2e
42bbc442dce02524e3744d60efd9085e4bbbe354
/GameBoiC/cpu.hpp
67c9eae736e09c7ddf25dcb217f77b97532dc63d
[]
no_license
TianranWang/GameBoiC
544eb25ab6996108a73e298d6d995cab53d43974
7e121a45572fa154a64c25f0968cdceef696af13
refs/heads/master
2021-01-12T04:46:28.916459
2017-01-12T01:15:27
2017-01-12T01:15:27
77,791,576
2
0
null
null
null
null
UTF-8
C++
false
false
2,658
hpp
// // cpu.hpp // GameBoiC // // Created by Tianran on 2017-01-01. // Copyright © 2017 Tianran. All rights reserved. // #ifndef cpu_hpp #define cpu_hpp #include <iostream> #include <functional> #include <vector> #include "memory.hpp" typedef std::vector<std::function<void()>> FnMap; struct Registers { uint8_t a, b, c, d, e, h, l, f; uint16_t pc, sp; }; class CPU { public: Registers reg; FnMap opcode_map; MMU memory; int total_clock; int last_instr_clock; CPU(); void reset(); private: void NOP(); void STOP(); // n <- 8 bit immediate value // r <- register // m <- value at MEM[(high<<8) + low] // 8-bit loads // LD r, n // r <- n // r = regs // n = imediate value // clock = 2 void LDrn_an(); void LDrn_bn(); void LDrn_cn(); void LDrn_dn(); void LDrn_en(); void LDrn_hn(); void LDrn_ln(); // LD r1, r2 // r1 <- r2 // r1, r2 = a b c d e h l (hl) void LDrr_aa(); void LDrr_ab(); void LDrr_ac(); void LDrr_ad(); void LDrr_ae(); void LDrr_ah(); void LDrr_al(); void LDrm_ahl(); // clock cycle = 2 void LDrr_ba(); void LDrr_bb(); void LDrr_bc(); void LDrr_bd(); void LDrr_be(); void LDrr_bh(); void LDrr_bl(); void LDrm_bhl(); // clock cycle = 2 void LDrr_ca(); void LDrr_cb(); void LDrr_cc(); void LDrr_cd(); void LDrr_ce(); void LDrr_ch(); void LDrr_cl(); void LDrm_chl(); // clock cycle = 2 void LDrr_da(); void LDrr_db(); void LDrr_dc(); void LDrr_dd(); void LDrr_de(); void LDrr_dh(); void LDrr_dl(); void LDrm_dhl(); // clock cycle = 2 void LDrr_ea(); void LDrr_eb(); void LDrr_ec(); void LDrr_ed(); void LDrr_ee(); void LDrr_eh(); void LDrr_el(); void LDrm_ehl(); // clock cycle = 2 void LDrr_ha(); void LDrr_hb(); void LDrr_hc(); void LDrr_hd(); void LDrr_he(); void LDrr_hh(); void LDrr_hl(); void LDrm_hhl(); // clock cycle = 2 void LDrr_la(); void LDrr_lb(); void LDrr_lc(); void LDrr_ld(); void LDrr_le(); void LDrr_lh(); void LDrr_ll(); void LDrm_lhl(); // clock cycle = 2 void LDmr_hla(); // clock cycle = 4 void LDmr_hlb(); void LDmr_hlc(); void LDmr_hld(); void LDmr_hle(); void LDmr_hlh(); void LDmr_hll(); void LDmn_hln(); // clock cycle = 3 // special for reg.a void LDrm_abc(); void LDrm_ade(); void LDrm_ann(); }; #endif /* cpu_hpp */
[ "tianran@TianrandeiMac.local" ]
tianran@TianrandeiMac.local
e347d147900ae273e9bd83b9b6f53cca2f3a5f35
f1ee65fbe1ffc43c2aac45e41515f1987eb534a4
/src/net/third_party/quiche/src/quiche/quic/core/qpack/qpack_required_insert_count.cc
544dffefe1fde43883e2cf88facde210d06f55b0
[ "BSD-3-Clause" ]
permissive
klzgrad/naiveproxy
6e0d206b6f065b9311d1e12b363109f2d35cc058
8ef1cecadfd4e2b5d57e7ea2fa42d05717e51c2e
refs/heads/master
2023-08-20T22:42:12.511091
2023-06-04T03:54:34
2023-08-16T23:30:19
119,178,893
5,710
976
BSD-3-Clause
2023-08-05T10:59:59
2018-01-27T16:02:33
C++
UTF-8
C++
false
false
2,323
cc
// Copyright (c) 2019 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. #include "quiche/quic/core/qpack/qpack_required_insert_count.h" #include <limits> #include "quiche/quic/platform/api/quic_logging.h" namespace quic { uint64_t QpackEncodeRequiredInsertCount(uint64_t required_insert_count, uint64_t max_entries) { if (required_insert_count == 0) { return 0; } return required_insert_count % (2 * max_entries) + 1; } bool QpackDecodeRequiredInsertCount(uint64_t encoded_required_insert_count, uint64_t max_entries, uint64_t total_number_of_inserts, uint64_t* required_insert_count) { if (encoded_required_insert_count == 0) { *required_insert_count = 0; return true; } // |max_entries| is calculated by dividing an unsigned 64-bit integer by 32, // precluding all calculations in this method from overflowing. QUICHE_DCHECK_LE(max_entries, std::numeric_limits<uint64_t>::max() / 32); if (encoded_required_insert_count > 2 * max_entries) { return false; } *required_insert_count = encoded_required_insert_count - 1; QUICHE_DCHECK_LT(*required_insert_count, std::numeric_limits<uint64_t>::max() / 16); uint64_t current_wrapped = total_number_of_inserts % (2 * max_entries); QUICHE_DCHECK_LT(current_wrapped, std::numeric_limits<uint64_t>::max() / 16); if (current_wrapped >= *required_insert_count + max_entries) { // Required Insert Count wrapped around 1 extra time. *required_insert_count += 2 * max_entries; } else if (current_wrapped + max_entries < *required_insert_count) { // Decoder wrapped around 1 extra time. current_wrapped += 2 * max_entries; } if (*required_insert_count > std::numeric_limits<uint64_t>::max() - total_number_of_inserts) { return false; } *required_insert_count += total_number_of_inserts; // Prevent underflow, also disallow invalid value 0 for Required Insert Count. if (current_wrapped >= *required_insert_count) { return false; } *required_insert_count -= current_wrapped; return true; } } // namespace quic
[ "kizdiv@gmail.com" ]
kizdiv@gmail.com
91d010cf52920ee54cc37a2548fcfb2d20b6be93
7e86efe41b53a5175a51ec6cefa78af79392ddd6
/videomodule/BiliMovieDumux.cpp
378b8b18db06ea8964e5af7c973b3c3a234b097e
[]
no_license
zq54zquan/bili-bmg
4d42fec15114855ad76c9be0e2f80f00abab3c3d
980847ecad05f736bfe4ea68f1ac15ac78ffb076
refs/heads/master
2021-05-05T19:46:14.022292
2018-03-09T08:54:40
2018-03-09T08:56:05
117,851,041
0
0
null
null
null
null
UTF-8
C++
false
false
3,395
cpp
// // Created by 周权 on 2018/2/22. // #include "BiliMovieDumux.h" #include <cstdio> #include <string> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libswscale/swscale.h> #include <libavdevice/avdevice.h> #include <libavutil/avutil.h> } using string = std::string; void BiliMovieDumux::process() { printf("begin process"); string output_path = this->filePath.substr(0,this->filePath.size()-3)+"aac"; printf("audio path:%s",output_path.c_str()); AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx_audio = NULL; AVPacket pkt; AVOutputFormat *ofmt_audio = NULL; int audio_index = -1; int frame_index = 0; av_register_all(); if (0!=avformat_open_input(&ifmt_ctx,this->filePath.c_str(),NULL,NULL)) { printf("open failed"); return; } if (avformat_find_stream_info(ifmt_ctx,NULL)<0) { printf("find stream failed"); return; } avformat_alloc_output_context2(&ofmt_ctx_audio,NULL,NULL,output_path.c_str()); if (!ofmt_ctx_audio) { printf("create ctx failed"); return; } ofmt_audio = ofmt_ctx_audio->oformat; for (int i = 0; i < ifmt_ctx->nb_streams; ++i) { AVFormatContext *ofmt_ctx; AVStream *instream = ifmt_ctx->streams[i]; AVStream *out_stream = NULL; if (AVMEDIA_TYPE_AUDIO==ifmt_ctx->streams[i]->codec->codec_type) { audio_index = i; out_stream = avformat_new_stream(ofmt_ctx_audio,instream->codec->codec); ofmt_ctx = ofmt_ctx_audio; }else { continue; } if (!out_stream) { printf("create stream failed"); return; } if (avcodec_copy_context(out_stream->codec,instream->codec)<0) { printf("copy stream codec failed"); return; } out_stream->codec->codec_tag = 0; if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) { out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; } } if (!(ofmt_audio->flags & AVFMT_NOFILE)) { if (avio_open(&ofmt_ctx_audio->pb,output_path.c_str(),AVIO_FLAG_WRITE)<0) { printf("open write file failed"); return; } } if (avformat_write_header(ofmt_ctx_audio,NULL)<0) { printf("write header file failed"); return; } while (1) { AVFormatContext *ofmt_ctx; AVStream *in_stream, *out_stream; if (av_read_frame(ifmt_ctx,&pkt)<0) break; in_stream = ifmt_ctx->streams[pkt.stream_index]; if (pkt.stream_index == audio_index) { out_stream = ofmt_ctx_audio->streams[0]; ofmt_ctx = ofmt_ctx_audio; printf("write audo packet.size:%d\t pts:%lld\n",pkt.size,pkt.pts); }else { continue; } pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX)); pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, (AVRounding)(AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX)); pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base); pkt.pos = -1; pkt.stream_index = 0; if (av_interleaved_write_frame(ofmt_ctx, &pkt) < 0) { printf("Error muxing packet\n"); break; } printf("Write %8d frames to output file\n",frame_index); av_free_packet(&pkt); frame_index++; } av_write_trailer(ofmt_ctx_audio); avformat_close_input(&ifmt_ctx); if (ofmt_ctx_audio &&!(ofmt_audio->flags & AVFMT_NOFILE)) avio_close(ofmt_ctx_audio->pb); avformat_free_context(ofmt_ctx_audio); }
[ "zhouquan02@bilibili.com" ]
zhouquan02@bilibili.com
d21cde22fcffd906de5b03bf681853511bb50a78
ccae3c9b20fa3c895042a1c7aa0815fd0faec141
/trunk/TestCode/EMBProject/Plugins/WorkPluginMD5/dllmain.cpp
720b2a11be955a385843eba19902e89f744650bb
[]
no_license
15831944/TxUIProject
7beaf17eb3642bcffba2bbe8eaa7759c935784a0
e90f3319ad0e57c0012e0e3a7e457851c2c6f0f1
refs/heads/master
2021-12-03T10:05:27.018212
2014-05-16T08:16:17
2014-05-16T08:16:17
null
0
0
null
null
null
null
GB18030
C++
false
false
1,443
cpp
// dllmain.cpp : 定义 DLL 的初始化例程。 // #include "stdafx.h" #include <afxwin.h> #include <afxdllx.h> #ifdef _DEBUG #define new DEBUG_NEW #endif static AFX_EXTENSION_MODULE WorkPluginMD5DLL = { NULL, NULL }; extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { // 如果使用 lpReserved,请将此移除 UNREFERENCED_PARAMETER(lpReserved); if (dwReason == DLL_PROCESS_ATTACH) { TRACE0("WorkPluginMD5.DLL 正在初始化!\n"); // 扩展 DLL 一次性初始化 if (!AfxInitExtensionModule(WorkPluginMD5DLL, hInstance)) return 0; // 将此 DLL 插入到资源链中 // 注意: 如果此扩展 DLL 由 // MFC 规则 DLL (如 ActiveX 控件)隐式链接到, // 而不是由 MFC 应用程序链接到,则需要 // 将此行从 DllMain 中移除并将其放置在一个 // 从此扩展 DLL 导出的单独的函数中。使用此扩展 DLL 的 // 规则 DLL 然后应显式 // 调用该函数以初始化此扩展 DLL。否则, // CDynLinkLibrary 对象不会附加到 // 规则 DLL 的资源链,并将导致严重的 // 问题。 new CDynLinkLibrary(WorkPluginMD5DLL); } else if (dwReason == DLL_PROCESS_DETACH) { TRACE0("WorkPluginMD5.DLL 正在终止!\n"); // 在调用析构函数之前终止该库 AfxTermExtensionModule(WorkPluginMD5DLL); } return 1; // 确定 }
[ "tyxwgy@sina.com" ]
tyxwgy@sina.com
033f55d879b94baa66236a13b2383b738bec71ce
747f92b60d75f3754222c3efa66f7cc765050bfd
/examples/octree_example.cpp
04d3fc9b6cf791d585a18a21d607708dbe677180
[ "MIT" ]
permissive
nlamprian/OCLSLAM
c6fcd1e694416782b807d61b8900f6de4df93c14
3cc7d664c525dc5539b59147bc3d1f5e63a143f2
refs/heads/master
2023-02-05T17:00:54.004072
2020-12-27T17:05:29
2020-12-27T17:05:29
38,508,786
18
6
null
null
null
null
UTF-8
C++
false
false
3,848
cpp
/*! \file octree_example.cpp * \brief An example demonstrating the integration of a 3-D point cloud * in an `octomap::OcTree`. * \note **Command line arguments**: * \note `res`: Octree leaf resolution in meters (defaults to 10 cm). * \note **Usage example**: * \note `./bin/oclslam_octree_example 0.01` * \author Nick Lamprianidis * \version 0.1.0 * \date 2015 * \copyright The MIT License (MIT) * \par * Copyright (c) 2015 Nick Lamprianidis * \par * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * \par * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * \par * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include <iostream> #include <vector> #include <string> #include <CLUtils.hpp> #include <octomap/octomap.h> #include <octomap/OcTree.h> /*! \brief Reads in a binary file. * * \param[in] path path to the file. * \param[out] data array that receives the data. * \param[in] n number of bytes to read. */ void fread (const char *path, char *data, size_t n) { std::ifstream f (path, std::ios::binary); f.read (data, n); f.close (); } int main(int argc, char** argv) { std::string filename = std::string ("../data/pc8d.bin"); // Coordinates in mm const int n = 640 * 480; std::vector<cl_float8> pc8d (n); std::cout << std::endl << "Reading point cloud data from " << filename << std::endl; fread (filename.c_str (), (char *) pc8d.data (), n * sizeof (cl_float8)); double res = (argc > 1) ? std::stod (argv[1]) : 0.1; // m std::cout << "Creating empty octree with leaf resolution of " << 100.0 * res << " cm" << std::endl; octomap::OcTree tree (res); std::cout << "Initializing point cloud structure" << std::endl; octomap::Pointcloud pc; size_t m = 0; for (cl_float8 &pp : pc8d) { cl_float *p = (cl_float *) &pp; if (p[0] != 0.f && p[1] != 0.f && p[2] != 0.f) { pc.push_back (p[0] / 1000.f, p[1] / 1000.f, p[2] / 1000.f); m++; } } std::cout << "Done. Initialized with " << m << "/" << n << " valid points" << std::endl; clutils::CPUTimer<double, std::milli> cTimer; std::cout << "Populating octree with point cloud" << std::endl; cTimer.start (); tree.insertPointCloud (pc, octomap::point3d (0, 0, 0), -1, false, true); cTimer.stop (); std::cout << "Done. Elapsed time is "; if (cTimer.duration () < 1000.0) std::cout << cTimer.duration () << " ms" << std::endl; else std::cout << cTimer.duration () / 1000.0 << " s" << std::endl; std::cout << "Writing octree in ./octree.ot" << std::endl; tree.write ("octree.ot"); // tree.writeBinary ("octree.bt"); std::cout << "=============================================================" << std::endl; std::cout << "Visualize the tree in octovis by running: octovis ./octree.ot" << std::endl << std::endl; }
[ "pAIgn10.ln@gmail.com" ]
pAIgn10.ln@gmail.com
a13fc95962c9b4be35b99040b740106c684764d5
ad7b48af9bd85f5c48b56813d08290e3653dc664
/ConsoleApplication1/Node.h
f1e6247f8d4988b67aafaf9defceeb77fefc9275
[]
no_license
khoavuong/Unrolled-linked-list
575112005089aca66fc42df4264575c156309867
279413c639b33857b62d657d6bdf98059f277759
refs/heads/master
2020-05-25T12:03:17.089622
2019-05-21T08:05:28
2019-05-21T08:05:28
184,848,089
1
0
null
null
null
null
UTF-8
C++
false
false
972
h
/* Copyright (C) 2018 * Course: CO2003 * Author: Rang Nguyen * Ho Chi Minh City University of Technology */ #pragma once #include <iostream> // Unrolled Linked List Node class Node { private: int maxElements; public: int numElements; // number of elements in this node, up to maxElements int* elements; // an array of numElements elements, Node *next; // reference to the next node in the list Node *prev; // reference to the previous node in the list Node(int capacity = 5); ~Node(); int getHalfNodeSize(); bool isUnderHalfFull(); bool isFull(); bool isOverflow(); bool isEmpty(); void add(int val); // append val element to the end of the node void insertAt(int pos, int val); // insert val to position pos of the node void removeAt(int pos); // remove the position pos from the node void reverse(); // reverse the content of the node void print(); // print the content of the node void printDetail(); // print the detail content of the node };
[ "50255410+khoavuong@users.noreply.github.com" ]
50255410+khoavuong@users.noreply.github.com
55f282f70a76485cc2781a382351e2cfb49d4f70
d80c9c6ba63eb1bfe5673c65811f4d64ce9f4782
/Physics/TinySprayParticle.cpp
3b421cbb25460347d7c88a66674ff1eccb46c40c
[ "Zlib", "MIT" ]
permissive
PremiumGraphicsCodes/CGLib
5d7c1a7d3e9e26b08e8df0adce4748785759e965
c63839da9d4f87b34ca497a2147a916b8180041f
refs/heads/master
2022-12-14T21:25:13.413152
2022-12-07T00:49:34
2022-12-07T00:49:34
49,645,980
1
1
null
null
null
null
UTF-8
C++
false
false
413
cpp
#include "TinySprayParticle.h" using namespace Crystal::Math; using namespace Crystal::Physics; TinySprayParticle::TinySprayParticle(const Vector3d<float>& position, const Vector3d<float>& velocity, BubbleParticle* parent) : ITinyParticle(position, velocity, parent) { } void TinySprayParticle::updateVelocity(const float dt, const Vector3d<float>& gravity) { this->velocity += dt * gravity; }
[ "mabuchi@premiumgraphics.co.jp" ]
mabuchi@premiumgraphics.co.jp
c699ede426aa4c7aecdb616bc70445b23ee776ba
f2fcd877b4b247d115250d18dec3f382086807b0
/src/ui/views/Debug.cc
ee3e49cb1c9bb5a1e3e4413af014c275d0b2374f
[ "MIT" ]
permissive
JaredYeDH/sparkle
8a6e30fca3b800fb14d53b8d34662612cbe82edc
998c56172fc4a56540737393f2e4b918304d1359
refs/heads/master
2020-03-17T16:36:44.988958
2018-04-15T22:53:19
2018-04-15T22:53:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
351
cc
#include "ui/views/Debug.h" #include "imgui.h" namespace views { void Debug::render() { if (!ImGui::CollapsingHeader("Debug")) { return; } ImGui::Checkbox("Show grid", &params_.show_grid); ImGui::Checkbox("Show simulation volume", &params_.show_simulation_volume); ImGui::Checkbox("Freeze", &params_.freeze); } } // namespace views
[ "tcoppex@gmail.com" ]
tcoppex@gmail.com
cd59a66c04da924793c040bc74675a4f4b49189a
de3adbc888ad1686e3758ed2d3f27dbef469101d
/Midterm/P4/linearMap.cpp
6ac2db9193ef5201c1268417853d9cd4bec231fa
[]
no_license
LouieBHLu/VE280_2020_Summer
616426593f44ae6990a28ad8274085340d3501c9
f04309a751924c4cb29833801bf7824870557863
refs/heads/master
2023-02-16T01:01:48.077715
2021-01-13T12:45:24
2021-01-13T12:45:24
270,972,820
4
2
null
null
null
null
UTF-8
C++
false
false
274
cpp
#include <iostream> #include <sstream> #include "linearMap.h" LinearMap::LinearMap(Vector &a):a(a){ } double LinearMap::evaluate(Vector &v) { return a.dot(v); } std::string LinearMap::str(){ ostringstream os; os << a.toString() << " . x"; return os.str(); }
[ "lmx00518@qq.com" ]
lmx00518@qq.com
97a94f521cdd623bb1994598f9ab53edf2d104b9
cb142e98b043e7088f0fe009f5159928877acf1b
/AVW/AVW_Box/AVW_BOX_Nano_LcdShow_ok/AVW_BOX_Nano_LcdShow_ok.ino
86f43817f7d53d9b3788e42ad0021d00eabeeeb2
[]
no_license
wetnt/Arduino_public
ef30502b4a30e099a09e2617fd58fd3a9801cf13
4cc331e2f43dda0df8f78d9cfe924da130ca5df3
refs/heads/master
2021-01-23T09:38:43.302783
2019-09-12T00:29:43
2019-09-12T00:29:43
33,909,041
2
2
null
null
null
null
UTF-8
C++
false
false
793
ino
/*=================================================================== 1.电量测量盒子 2.AcMeter_60A //=================================================================*/ //=================================================================== void setup() { //------------------------------------------------ lgsetup("AVW_BOX_Nano_b ..."); //------------------------------------------------ LCD1602_setup(); LCD1602_Clear(); LCD1602_Show(0, 0, F("AVW_Nano_Start!")); //------------------------------------------------ AVW_Setup(); //------------------------------------------------ } void loop() { //--------------------------------- AVW_Loop(); LCD_Loop(true); RunTimeLoop(); //--------------------------------- lgFeed(); //--------------------------------- }
[ "jinping.xu@woqu.com" ]
jinping.xu@woqu.com
124735f5d3e632bb3d9e2bb0078827322e792127
b5aead43fef12a87df3ad139d108878997fa16cf
/fxconf3/fxconf3/fxc/Order.cpp
686a23cd35053ff1349796bb06e813b17e6d18d7
[]
no_license
kashtanoff/libzmq
34bb6aeb1fd23c2d4c81e38fcb6bd9ee9f25c639
a1dcf22f37a37817f2c9a73f07cadb25247430c1
refs/heads/master
2021-01-21T01:44:39.137233
2015-08-24T23:30:32
2015-08-24T23:30:32
62,384,231
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
338
cpp
#pragma once namespace fxc { //Структура описывающая ордер, для хранения менеджером ордеров struct Order { int ticket; int type; int magic; double lots; double openprice; double tpprice; double slprice; double closeprice; double profit; bool checked; }; }
[ "o.o.n.joy@gmail.com" ]
o.o.n.joy@gmail.com
29174bdbea5877ec8c5e0e443eac889310065bd0
9e47d03a3fda5129dd47592ae41f509465194bba
/src/block2raw/block2raw.cpp
7d014d5f7dc9eb451ef0cfcd7dbdc9c0186f71d3
[]
no_license
cad420/VMTools
11b756f6210e1aa90e7b5426ee065da51d09b8e4
8e81ec1c4e11e3f71960ccc00a471e0f980febb9
refs/heads/master
2021-06-19T20:23:24.011771
2021-05-14T04:54:01
2021-05-14T04:54:01
212,283,221
0
0
null
null
null
null
UTF-8
C++
false
false
4,442
cpp
#include <VMUtils/cmdline.hpp> #include <VMCoreExtension/i3dblockfileplugininterface.h> #include <VMUtils/log.hpp> #include <VMat/numeric.h> #include <VMFoundation/pluginloader.h> #include <fstream> //#define USE_MAPPING int main(int argc, char** argv) { cmdline::parser a; vm::PluginLoader::GetPluginLoader()->LoadPlugins("plugins"); a.add<std::string>("if", 'i', "input file", true); a.add<std::string>("of", 'o', "output file", false, "a"); a.add<std::string>("fmt", 'f', "file format", true, ".lvd"); a.parse_check(argc, argv); const auto key = a.get<std::string>("fmt"); auto reader = vm::PluginLoader::CreatePlugin<I3DBlockFilePluginInterface>(key); if (reader == nullptr) { vm::println("failed to load plugin for {}", key); return 0; } try { reader->Open(a.get<std::string>("if")); } catch (std::exception & e) { ::vm::println("{}", e.what()); } const auto pageCount = reader->Get3DPageCount(); vm::println("Total blocks:{}", pageCount); #ifdef USE_MAPPING ::vm::Ref<IFileMapping> file; #ifdef _WIN32 file = ysl::PluginLoader::CreatePlugin<IFileMapping>("windows"); #else file = ysl::PluginLoader::CreatePlugin<IFileMapping>("linux"); #endif #endif const auto ods = reader->GetDataSizeWithoutPadding(); // original data size std::stringstream ss; ss << a.get<std::string>("of") << "_" << ods.x << "_" << ods.y << "_" << ods.z << ".raw"; std::string out; ss >> out; ::vm::println("Data Size:{}", ods); #ifdef USE_MAPPING try { if (file->Open(out, ods.Prod(), FileAccess::ReadWrite, MapAccess::ReadWrite) == false) { ::vm::println("Failed to open file {}", a.get<std::string>("of")); } } catch (std::exception & e) { ::vm::println("{}", e.what()); } void* data = file->FileMemPointer(0, ods.Prod()); if (data == nullptr) { ::vm::println("Failed to map file"); } #endif const auto p = reader->GetPadding(); // padding const auto bs = reader->Get3DPageSize(); // page size const auto _ = bs - 2 * vm::Size3(p, p, p); const vm::Vec3i bsnp = vm::Vec3i(_.x, _.y, _.z); // block size without padding ::vm::println("PageSize: {}", bs); ::vm::println("PageSizeNoPadding: {}", bsnp); std::ofstream fileStream(out, std::ios::binary); if (fileStream.is_open() == false) { ::vm::println("Failed to open file: {}", out); return 1; } const auto bufSize = ods.x * ods.y * bsnp.z; std::vector<char> buf; buf.reserve(bufSize); ::vm::println("Buf Size: {}", bufSize); auto totalBytes = 0; for (int zb = 0; zb < pageCount.z; zb++) { bool end = false; int lastSlice = bsnp.z; size_t realBuf = bufSize; if (zb == pageCount.z - 1) { lastSlice = ods.z % bsnp.z; realBuf = ods.x * ods.y * lastSlice; } for (int yb = 0; yb < pageCount.y; yb++) { for (int xb = 0; xb < pageCount.x; xb++) { // for each block, read the all the strip memory region of x direction const auto bid = vm::Linear({ xb, yb, zb }, { pageCount.x, pageCount.y }); const auto block = reinterpret_cast<const char*>(reader->GetPage(bid)); for (int sz = 0; sz < lastSlice; sz++) { for (int sy = 0; sy < bsnp.y; sy++) { const auto blockBegin = vm::Linear({ p, p + sy, p + sz }, { bs.x, bs.y }); const auto bufBegin = vm::Linear({ xb * bsnp.x, yb * bsnp.y, sz }, { ods.x, ods.y }); memcpy(buf.data() + bufBegin, block + blockBegin, bsnp.x); } } } } totalBytes += realBuf; fileStream.write(buf.data(), realBuf); vm::println("Level: {}, Bytes: {} = {} x {} x {}", zb, realBuf, ods.x, ods.y, lastSlice); } vm::println("Written bytes in total: {}", totalBytes); #ifdef USE_MAPPING for (int z = 0; z < ods.z; z++) { const auto zb = z / bsnp.z; // block x id for (int y = 0; y < ods.y; y++) { // block y id const auto yb = y / bsnp.y; for (int x = 0; x < ods.x; x++) { const auto xb = x / bsnp.x; const auto bid = ysl::Linear({ int(xb), int(yb), int(zb) }, { pageCount.x, pageCount.y }); // linear block id const auto block = reader->GetPage(bid); const auto globalOffset = ysl::Linear({ x, y, z }, { ods.x, ods.y }); assert(globalOffset < ods.Prod()); const ysl::Point3i pos = { x % bsnp.x + p, y % bsnp.y + p, z % bsnp.z + p }; const auto blockOffset = ysl::Linear(pos, { bs.x, bs.y }); assert(blockOffset < bs.Prod()); *(reinterpret_cast<char*>(data) + globalOffset) = *(reinterpret_cast<const char*>(block) + blockOffset); } } } file->Close(); #endif return 0; }
[ "yangshuoliu@sina.com" ]
yangshuoliu@sina.com
fbab147992c9a37e478d3de72d1232934f2f5146
9e397ee0cf4e17702893913694904ece6bfabce6
/include/gtulu/internal/texture_unit.hpp
955189b7c9c31e3c8734ac245cb25c68f91cba14
[ "BSL-1.0" ]
permissive
ierror/libgtulu
d3511cf4e4f3afa4be4a7a05007c5a2b4fa62996
abb995ef5e184f3902b5d07c2312d532e381c4a6
refs/heads/master
2021-01-17T06:20:30.945101
2014-02-09T09:31:43
2014-02-09T09:31:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
343
hpp
/** * @file * * Distributed under the Boost Software License, Version 1.0. * See accompanying file LICENSE or copy at http://www.boost.org/LICENSE */ #ifndef GTULU_INTERNAL_TEXTURE_UNIT_HPP_ #define GTULU_INTERNAL_TEXTURE_UNIT_HPP_ #include "gtulu/namespaces.hpp" struct texture_unit {}; #endif /* GTULU_INTERNAL_TEXTURE_UNIT_HPP_ */
[ "beren.minor+git@gmail.com" ]
beren.minor+git@gmail.com
15dbc15fdad4452968f26f9197c967f906618a45
e3d917181ee947fe596df4b66e1bdc066e9f9e02
/windowsbuild/MSVC2022/Qt/6.4.2/include/QtGui/qtextoption.h
dcff41584f08ab825c502e144f2f08ee6a7e507b
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
visit-dav/visit-deps
d1be0023fa4c91c02589e5d87ab4e48c99145bb5
d779eb48a12e667c3b759cedd3732053d7676abf
refs/heads/master
2023-08-08T15:30:28.412508
2023-07-31T22:34:52
2023-07-31T22:34:52
174,021,407
2
3
NOASSERTION
2023-07-06T16:07:22
2019-03-05T21:12:14
C++
UTF-8
C++
false
false
3,331
h
// Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTEXTOPTION_H #define QTEXTOPTION_H #include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtCore/qchar.h> #include <QtCore/qmetatype.h> QT_BEGIN_NAMESPACE struct QTextOptionPrivate; class Q_GUI_EXPORT QTextOption { public: enum TabType { LeftTab, RightTab, CenterTab, DelimiterTab }; struct Q_GUI_EXPORT Tab { inline Tab() : position(80), type(QTextOption::LeftTab) { } inline Tab(qreal pos, TabType tabType, QChar delim = QChar()) : position(pos), type(tabType), delimiter(delim) {} inline bool operator==(const Tab &other) const { return type == other.type && qFuzzyCompare(position, other.position) && delimiter == other.delimiter; } inline bool operator!=(const Tab &other) const { return !operator==(other); } qreal position; TabType type; QChar delimiter; }; QTextOption(); Q_IMPLICIT QTextOption(Qt::Alignment alignment); ~QTextOption(); QTextOption(const QTextOption &o); QTextOption &operator=(const QTextOption &o); inline void setAlignment(Qt::Alignment alignment); inline Qt::Alignment alignment() const { return Qt::Alignment(align); } inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; } inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); } enum WrapMode { NoWrap, WordWrap, ManualWrap, WrapAnywhere, WrapAtWordBoundaryOrAnywhere }; inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; } inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); } enum Flag { ShowTabsAndSpaces = 0x1, ShowLineAndParagraphSeparators = 0x2, AddSpaceForLineAndParagraphSeparators = 0x4, SuppressColors = 0x8, ShowDocumentTerminator = 0x10, IncludeTrailingSpaces = 0x80000000 }; Q_DECLARE_FLAGS(Flags, Flag) inline void setFlags(Flags flags); inline Flags flags() const { return Flags(f); } inline void setTabStopDistance(qreal tabStopDistance); inline qreal tabStopDistance() const { return tab; } void setTabArray(const QList<qreal> &tabStops); QList<qreal> tabArray() const; void setTabs(const QList<Tab> &tabStops); QList<Tab> tabs() const; void setUseDesignMetrics(bool b) { design = b; } bool useDesignMetrics() const { return design; } private: uint align : 9; uint wordWrap : 4; uint design : 1; uint direction : 2; uint unused : 16; uint f; qreal tab; QTextOptionPrivate *d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags) inline void QTextOption::setAlignment(Qt::Alignment aalignment) { align = uint(aalignment.toInt()); } inline void QTextOption::setFlags(Flags aflags) { f = uint(aflags.toInt()); } inline void QTextOption::setTabStopDistance(qreal atabStop) { tab = atabStop; } QT_END_NAMESPACE QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT) #endif // QTEXTOPTION_H
[ "noreply@github.com" ]
noreply@github.com
44e3bacf9a7a29b118c367a26e3d7b4cef905c81
57f9327568ce8ee02b4b504afb75d35517585211
/Image_Segmentation/Adaptive_threshold_segmentation.cpp
84ddacef3d31c54b6a80dd02ed55358c2ef743b9
[]
no_license
memesoo99/CV_ImageProcessing
39a844f8f703ed6c93b3a6f8bf5d29545420e3bc
7e5b5de036e557675dcd6df61c0d6331eafc2136
refs/heads/main
2023-04-21T06:10:45.785142
2021-05-15T16:59:53
2021-05-15T16:59:53
357,417,732
4
0
null
null
null
null
UTF-8
C++
false
false
2,384
cpp
#include <iostream> #include <opencv2/opencv.hpp> #define IM_TYPE CV_8UC3 using namespace cv; // Image Type // "G" for GrayScale Image, "C" for Color Image #if (IM_TYPE == CV_8UC3) typedef uchar G; typedef cv::Vec3b C; #elif (IM_TYPE == CV_16SC3) typedef short G; typedef Vec3s C; #elif (IM_TYPE == CV_32SC3) typedef int G; typedef Vec3i C; #elif (IM_TYPE == CV_32FC3) typedef float G; typedef Vec3f C; #elif (IM_TYPE == CV_64FC3) typedef double G; typedef Vec3d C; #endif Mat adaptive_thres(const Mat input, int n, float b); int main() { Mat input = imread("writing.jpg", IMREAD_COLOR); Mat input_gray; Mat output; cvtColor(input, input_gray, COLOR_RGB2GRAY); // Converting image to gray if (!input.data) { std::cout << "Could not open" << std::endl; return -1; } namedWindow("Grayscale", WINDOW_AUTOSIZE); imshow("Grayscale", input_gray); output = adaptive_thres(input_gray, 2, 0.9); //Fix with uniform mean filtering with zero paddle namedWindow("Adaptive", WINDOW_AUTOSIZE); imshow("Adaptive_threshold", output); waitKey(0); return 0; } Mat adaptive_thres(const Mat input, int n, float bnumber) { Mat kernel; int row = input.rows; int col = input.cols; int kernel_size = (2 * n + 1); // Initialiazing Kernel Matrix kernel = Mat::ones(kernel_size, kernel_size, CV_32F) / (float)(kernel_size * kernel_size); float kernelvalue = kernel.at<float>(0, 0); // To simplify, as the filter is uniform. All elements of the kernel value are same. Mat output = Mat::zeros(row, col, input.type()); for (int i = 0; i < row; i++) { //for each pixel in the output for (int j = 0; j < col; j++) { float sum1 = 0.0; for (int a = -n; a <= n; a++) { // for each kernel window for (int b = -n; b <= n; b++) { if ((i + a <= row - 1) && (i + a >= 0) && (j + b <= col - 1) && (j + b >= 0)) { //if the pixel is not a border pixel kernelvalue=kernel.at<float>(a+n, b+n); sum1 += kernelvalue*(float)(input.at<G>(i + a, j + b)); } } } float temp = bnumber*(G)sum1; if (input.at<G>(i,j)>temp) output.at<G>(i,j) = 255; else output.at<G>(i,j) = 0; } } return output; }
[ "genniferk1234@gmail.com" ]
genniferk1234@gmail.com
fd5e1fc6d34f84ec50b9d4d3c05c8d1f437d8cb7
ebb70b0cbe7626366077cbb66a58334aaf880f49
/slm_models/gecode.framework/Versions/44/include/set/trace/traits.hpp
9f028bf243f6943ddb3f5d17cf96eefc2b75cb4a
[ "MIT" ]
permissive
slemouton/gecodeMCP
fa06936f5159a56829a61825e90b3a297fef78dd
d038c52ffcf7351048fe5a018cee29c432d8184f
refs/heads/master
2021-07-10T22:33:26.858361
2021-05-05T21:03:55
2021-05-05T21:03:55
60,289,358
1
1
MIT
2019-01-12T16:58:17
2016-06-02T18:52:11
C++
UTF-8
C++
false
false
1,818
hpp
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte <schulte@gecode.org> * * Copyright: * Christian Schulte, 2016 * * Last modified: * $Date: 2017-03-18 09:04:57 +1100 (Sat, 18 Mar 2017) $ by $Author: schulte $ * $Revision: 15597 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Gecode { /// Trace traits for set views template<> class TraceTraits<Set::SetView> { public: typedef Set::SetTraceView TraceView; typedef SetTraceDelta TraceDelta; typedef unsigned long long int SlackValue; }; } // STATISTICS: set-trace
[ "lemouton@ircam.Fr" ]
lemouton@ircam.Fr
d682eb3e44a992a66ba265830d47c7f3a42de25f
8b275a2874f7b8f9a64cdde2bf4686c3a61710cf
/mv_driver/mvIMPACT_acquire/apps/mvPropView/VectorScopeCanvas.cpp
784da9b093d54a3507325d0c07be8cf77a93d969
[]
no_license
zheng-rong/matrix_camera
64a8d17052c0dfc094c87e48a38c859ff5cbb8ed
61c932d0864f197359f0dec83b83d397e760d24d
refs/heads/master
2021-01-15T15:50:45.808796
2016-11-06T07:57:24
2016-11-06T07:57:24
30,679,073
1
0
null
null
null
null
UTF-8
C++
false
false
23,472
cpp
#include "DataGrid.h" #include "VectorScopeCanvas.h" //#define TEST_VECTOR_SCOPE #ifdef TEST_VECTOR_SCOPE # define VECTOR_SCOPE_TEST_VALUE_COUNT 1024 #endif // #ifdef TEST_VECTOR_SCOPE //============================================================================= //============== Implementation VectorScopeCanvas ============================= //============================================================================= //----------------------------------------------------------------------------- VectorScopeCanvas::VectorScopeCanvas( wxWindow* parent, wxWindowID id /* = -1 */, const wxPoint& pos /* = wxDefaultPosition */, const wxSize& size /* = wxDefaultSize */, long style /* = wxSUNKEN_BORDER */, const wxString& name /* = wxT("Vector Scope") */, bool boActive /* = false */ ) : PlotCanvasImageAnalysis( parent, wxT( "VectorScope" ), id, pos, size, style, name, boActive, 1 ), m_pDataBuffer( 0 ), m_MaxPixelValue( VAL_COUNT_8_BIT ) //----------------------------------------------------------------------------- { m_plotFeatures.insert( pfGridSteps ); InitReferencePoints( 0 ); SetGridValueFormatString( wxT( "%.3f" ) ); } //----------------------------------------------------------------------------- VectorScopeCanvas::~VectorScopeCanvas() //----------------------------------------------------------------------------- { DeallocateDataBuffer(); } //----------------------------------------------------------------------------- void VectorScopeCanvas::CreateGridCustom( void ) //----------------------------------------------------------------------------- { m_pNumericalDisplay->SetTable( new DataGridTable( this, m_valCount, 3 ), true ); m_pNumericalDisplay->SetCellBackgroundColour( 0, pCb, *wxBLUE ); m_pNumericalDisplay->SetCellTextColour( 0, pCb, *wxWHITE ); m_pNumericalDisplay->SetCellBackgroundColour( 0, pCr, *wxRED ); m_pNumericalDisplay->SetCellTextColour( 0, pCr, *wxWHITE ); } //----------------------------------------------------------------------------- void VectorScopeCanvas::DeallocateDataBuffer( void ) //----------------------------------------------------------------------------- { delete [] m_pDataBuffer; m_pDataBuffer = 0; } //----------------------------------------------------------------------------- wxString VectorScopeCanvas::GetGridValue( int row, int col ) const //----------------------------------------------------------------------------- { if( col == 0 ) { return ( row == 0 ) ? wxT( "Data Point in AOI" ) : wxString::Format( wxT( "%d" ), row - 1 ); } else if( ( row >= 0 ) && ( col > 0 ) ) { if( row == 0 ) { switch( col - 1 ) { case 0: return wxString( wxT( "Cb" ) ); case 1: return wxString( wxT( "Cr" ) ); default: wxASSERT_MSG( false, wxT( "Invalid colum count" ) ); break; } } else if( m_pDataBuffer && ( static_cast<unsigned int>( row - 1 ) < m_valCount ) ) { switch( col - 1 ) { case 0: return wxString::Format( GetGridValueFormatString().c_str(), m_pDataBuffer[row - 1].Cb_ ); case 1: return wxString::Format( GetGridValueFormatString().c_str(), m_pDataBuffer[row - 1].Cr_ ); default: wxASSERT_MSG( false, wxT( "Invalid colum count" ) ); break; } } } return wxEmptyString; } //----------------------------------------------------------------------------- void VectorScopeCanvas::InitReferencePoints( int bitShift ) //----------------------------------------------------------------------------- { m_ReferencePoints[rcRed ].Set( 255 << bitShift, 0 , 0 , bitShift ); m_ReferencePoints[rcYellow ].Set( 255 << bitShift, 255 << bitShift, 0 , bitShift ); m_ReferencePoints[rcGreen ].Set( 0 , 255 << bitShift, 0 , bitShift ); m_ReferencePoints[rcCyan ].Set( 0 , 255 << bitShift, 255 << bitShift, bitShift ); m_ReferencePoints[rcBlue ].Set( 0 , 0 , 255 << bitShift, bitShift ); m_ReferencePoints[rcMagenta].Set( 255 << bitShift, 0 , 255 << bitShift, bitShift ); } //----------------------------------------------------------------------------- void VectorScopeCanvas::OnPaintCustom( wxPaintDC& dc ) //----------------------------------------------------------------------------- { if( !m_pDataBuffer ) { return; } wxCoord w( 0 ), h( 0 ); dc.GetSize( &w, &h ); const int RADIUS = ( ( ( w < h ) ? w : h ) - GetBorderWidth() ) / 2; const double scaleFactor = static_cast<double>( 2 * RADIUS ) / ( 1.0554 * static_cast<double>( m_MaxPixelValue ) ); const wxPoint CENTER( w / 2, h / 2 ); if( m_boUnsupportedPixelFormat ) { dc.SetBrush( *wxBLACK_BRUSH ); dc.DrawRectangle( 0, 0, w, h ); dc.SetTextForeground( *wxRED ); dc.DrawText( wxString( wxT( "Unsupported pixel format" ) ), CENTER.x, CENTER.y ); } else { wxImage pixelCloud( w, h ); for( unsigned int i = 0; i < m_valCount; i++ ) { pixelCloud.SetRGB( CENTER.x + static_cast<int>( m_pDataBuffer[i].Cb_ * scaleFactor ), CENTER.y - static_cast<int>( m_pDataBuffer[i].Cr_ * scaleFactor ), m_pDataBuffer[i].colour_.Red(), m_pDataBuffer[i].colour_.Green(), m_pDataBuffer[i].colour_.Blue() ); } wxMemoryDC memDC; wxBitmap pixelBitmap( pixelCloud, -1 ); memDC.SelectObject( pixelBitmap ); dc.Blit( 0, 0, w, h, &memDC, 0, 0 ); } dc.SetBrush( *wxTRANSPARENT_BRUSH ); const wxCoord rectSize( 6 ); for( int i = 0; i < rcLAST; i++ ) { dc.SetPen( wxColour( m_ReferencePoints[i].colour_ ) ); int xOffsetFromCenter = static_cast<int>( m_ReferencePoints[i].Cb_ * scaleFactor ); int yOffsetFromCenter = static_cast<int>( m_ReferencePoints[i].Cr_ * scaleFactor ); dc.DrawRectangle( CENTER.x + xOffsetFromCenter - ( rectSize / 2 ), CENTER.y - yOffsetFromCenter - ( rectSize / 2 ), rectSize, rectSize ); } dc.SetPen( wxColour( 128, 128, 128 ) ); dc.DrawCircle( CENTER, RADIUS ); dc.DrawCircle( CENTER, 3 * RADIUS / 4 ); dc.DrawCircle( CENTER, RADIUS / 2 ); dc.DrawCircle( CENTER, RADIUS / 4 ); } //----------------------------------------------------------------------------- void VectorScopeCanvas::PrepareDataBuffer( bool boAOIChanged ) //----------------------------------------------------------------------------- { unsigned int newValCount = ( ( m_AOIw + m_GridStepsX - 1 ) / m_GridStepsX ) * ( ( m_AOIh + m_GridStepsY - 1 ) / m_GridStepsY ); if( boAOIChanged || !m_pDataBuffer || ( newValCount != m_valCount ) ) { DeallocateDataBuffer(); #ifndef TEST_VECTOR_SCOPE m_valCount = newValCount; #else m_valCount = VECTOR_SCOPE_TEST_VALUE_COUNT; #endif // #ifndef TEST_VECTOR_SCOPE m_pDataBuffer = new DataPoint[m_valCount]; } } //----------------------------------------------------------------------------- template<typename _Ty> void VectorScopeCanvas::ProcessMonoPackedData( const ImageBuffer* pIB, DataPoint* p, const int bitShift, _Ty pixelAccessFn ) //----------------------------------------------------------------------------- { // no colour information, thus it doesn't make much sense to calculate all the information as the one // and only point drawn will be in the center of the plot using the intensity of the last pixel calculated. // However no one shall be able to say we are not trying hard. for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { const int pixOffset = ( m_AOIy + line ) * pIB->iWidth; for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { unsigned short value = pixelAccessFn( static_cast<unsigned char*>( pIB->vpData ), pixOffset + m_AOIx + m_AOIw ); p->Set( value, value, value, bitShift ); ++p; } } } //----------------------------------------------------------------------------- template<typename _Ty> void VectorScopeCanvas::ProcessUYV422Data( const ImageBuffer* pIB, DataPoint* p, const int bitShift ) //----------------------------------------------------------------------------- { if( pIB->iWidth > 1 ) { for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { _Ty* pData = reinterpret_cast<_Ty*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ) ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { if( ( m_AOIx + pixel ) & 1 ) { p->SetYUV( pData[1], pData[-2], pData[0], bitShift ); } else { p->SetYUV( pData[1], pData[0], pData[2], bitShift ); } ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } } } //----------------------------------------------------------------------------- template<typename _Ty> void VectorScopeCanvas::ProcessYUV411_UYYVYYData( const ImageBuffer* pIB, DataPoint* p, const int bitShift ) //----------------------------------------------------------------------------- { if( pIB->iWidth > 1 ) { ProcessingHelperYUV411_UYYVYY ph( m_AOIx ); int incOdd = 0; int incEven = 0; for( int i = 0; i < m_GridStepsX; i++ ) { incEven += ( i % 2 ) ? 2 : 1; incOdd += ( i % 2 ) ? 1 : 2; } for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { _Ty* pData = reinterpret_cast<_Ty*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pY].iLinePitch ) ) + ph.GetOffsetToFirstY(); for( int pixel = m_AOIx; pixel < m_AOIw + m_AOIx; pixel += m_GridStepsX ) { ph.RefreshUAndVOffsets( pixel ); p->SetYUV( pData[0], pData[ph.GetUOffset()], pData[ph.GetVOffset()], bitShift ); ++p; pData += ( pixel % 2 ) ? incOdd : incEven; } } } } //----------------------------------------------------------------------------- template<typename _Ty> void VectorScopeCanvas::ProcessYUV422Data( const ImageBuffer* pIB, DataPoint* p, const int bitShift ) //----------------------------------------------------------------------------- { if( pIB->iWidth > 1 ) { for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { _Ty* pData = reinterpret_cast<_Ty*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ) ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { if( ( m_AOIx + pixel ) & 1 ) { p->SetYUV( pData[0], pData[-1], pData[1], bitShift ); } else { p->SetYUV( pData[0], pData[1], pData[3], bitShift ); } ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } } } //----------------------------------------------------------------------------- void VectorScopeCanvas::RefreshData( const RequestData& data, int x /* = -1 */, int y /* = -1 */, int w /* = -1 */, int h /* = -1 */, bool boForceRefresh /* = false */ ) //----------------------------------------------------------------------------- { wxCriticalSectionLocker locker( m_critSect ); bool boAOIChanged = false; bool boImageFormatChanged = false; const ImageBuffer* pIB = data.image_.getBuffer(); if( !MustUpdate( pIB, pIB->iChannelCount, x, y, w, h, boForceRefresh, &boAOIChanged, &boImageFormatChanged ) ) { return; } m_ChannelCount = pIB->iChannelCount; PrepareDataBuffer( boAOIChanged ); DataPoint* p = m_pDataBuffer; int bitShift = 0; #ifndef TEST_VECTOR_SCOPE switch( pIB->pixelFormat ) { case ibpfMono10: case ibpfBGR101010Packed_V2: case ibpfRGB101010Packed: case ibpfYUV422_10Packed: case ibpfYUV422_UYVY_10Packed: case ibpfYUV444_UYV_10Packed: case ibpfYUV444_10Packed: m_MaxPixelValue = VAL_COUNT_10_BIT; bitShift = 2; break; case ibpfMono12: case ibpfMono12Packed_V1: case ibpfMono12Packed_V2: case ibpfRGB121212Packed: m_MaxPixelValue = VAL_COUNT_12_BIT; bitShift = 4; break; case ibpfMono14: case ibpfRGB141414Packed: m_MaxPixelValue = VAL_COUNT_14_BIT; bitShift = 6; break; case ibpfMono16: case ibpfRGB161616Packed: m_MaxPixelValue = VAL_COUNT_16_BIT; bitShift = 8; break; case ibpfMono8: case ibpfBGR888Packed: case ibpfRGBx888Packed: case ibpfRGB888Packed: case ibpfRGBx888Planar: case ibpfYUV411_UYYVYY_Packed: case ibpfYUV422Packed: case ibpfYUV422_UYVYPacked: case ibpfYUV444_UYVPacked: case ibpfYUV444Packed: case ibpfYUV422Planar: default: m_MaxPixelValue = VAL_COUNT_8_BIT; break; } InitReferencePoints( bitShift ); switch( pIB->pixelFormat ) { case ibpfMono8: // no colour information, thus it doesn't make much sense to calculate all the information as the one // and only point drawn will be in the center of the plot using the intensity of the last pixel calculated. // However no one shall be able to say we are not trying hard. for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pData = static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->Set( *pData, *pData, *pData, bitShift ); ++p; } } break; case ibpfMono10: case ibpfMono12: case ibpfMono14: case ibpfMono16: // no colour information, thus it doesn't make much sense to calculate all the information as the one // and only point drawn will be in the center of the plot using the intensity of the last pixel calculated. // However no one shall be able to say we are not trying hard. for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned short* pData = reinterpret_cast<unsigned short*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ) ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->Set( *pData, *pData, *pData, bitShift ); ++p; } } break; case ibpfMono12Packed_V1: ProcessMonoPackedData( pIB, p, bitShift, GetMono12Packed_V1Pixel ); break; case ibpfMono12Packed_V2: ProcessMonoPackedData( pIB, p, bitShift, GetMono12Packed_V2Pixel ); break; case ibpfBGR888Packed: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pData = static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->Set( pData[0], pData[1], pData[2], bitShift ); ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } break; case ibpfBGR101010Packed_V2: { unsigned short red, green, blue; for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned int* pPixel = reinterpret_cast<unsigned int*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[0].iLinePitch ) ) + m_AOIx; for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { GetBGR101010Packed_V2Pixel( *pPixel++, red, green, blue ); p->Set( red, green, blue, bitShift ); ++p; } } } break; case ibpfRGBx888Packed: case ibpfRGB888Packed: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pData = static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->Set( pData[2], pData[1], pData[0], bitShift ); ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } break; case ibpfRGB101010Packed: case ibpfRGB121212Packed: case ibpfRGB141414Packed: case ibpfRGB161616Packed: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned short* pData = reinterpret_cast<unsigned short*>( static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ) ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { unsigned short r = saveAssign( pData[2], static_cast<unsigned short>( 0 ), static_cast<unsigned short>( m_MaxPixelValue - 1 ) ); unsigned short g = saveAssign( pData[1], static_cast<unsigned short>( 0 ), static_cast<unsigned short>( m_MaxPixelValue - 1 ) ); unsigned short b = saveAssign( pData[0], static_cast<unsigned short>( 0 ), static_cast<unsigned short>( m_MaxPixelValue - 1 ) ); p->Set( r, g, b, bitShift ); ++p; pData += 3 * m_GridStepsX; } } break; case ibpfRGBx888Planar: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pr = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pRed].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + m_AOIx; unsigned char* pg = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pGreen].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pGreen].iLinePitch ) + m_AOIx; unsigned char* pb = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pBlue].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pBlue].iLinePitch ) + m_AOIx; for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->Set( *pr, *pg, *pb ); ++p; pr += m_GridStepsX; pg += m_GridStepsX; pb += m_GridStepsX; } } break; case ibpfYUV444_UYVPacked: case ibpfYUV444_UYV_10Packed: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pData = static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->SetYUV( pData[1], pData[2], pData[2], bitShift ); ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } break; case ibpfYUV444_10Packed: case ibpfYUV444Packed: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* pData = static_cast<unsigned char*>( pIB->vpData ) + ( ( m_AOIy + line ) * pIB->pChannels[pRed].iLinePitch ) + ( m_AOIx * pIB->iBytesPerPixel ); for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->SetYUV( pData[0], pData[1], pData[2], bitShift ); ++p; pData += pIB->iBytesPerPixel * m_GridStepsX; } } break; case ibpfYUV422Planar: for( int line = 0; line < m_AOIh; line += m_GridStepsY ) { unsigned char* py = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pY].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pY].iLinePitch ) + m_AOIx; unsigned char* pu = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pU].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pU].iLinePitch ) + m_AOIx; unsigned char* pv = static_cast<unsigned char*>( pIB->vpData ) + pIB->pChannels[pV].iChannelOffset + ( ( m_AOIy + line ) * pIB->pChannels[pV].iLinePitch ) + m_AOIx; for( int pixel = 0; pixel < m_AOIw; pixel += m_GridStepsX ) { p->SetYUV( *py, *pu, *pv ); ++p; py += m_GridStepsX; if( pixel % 2 ) { pu += m_GridStepsX; pv += m_GridStepsX; } } } break; case ibpfYUV411_UYYVYY_Packed: ProcessYUV411_UYYVYYData<unsigned char>( pIB, p, bitShift ); break; case ibpfYUV422Packed: ProcessYUV422Data<unsigned char>( pIB, p, bitShift ); break; case ibpfYUV422_10Packed: ProcessYUV422Data<unsigned short>( pIB, p, bitShift ); break; case ibpfYUV422_UYVYPacked: ProcessUYV422Data<unsigned char>( pIB, p, bitShift ); break; case ibpfYUV422_UYVY_10Packed: ProcessUYV422Data<unsigned short>( pIB, p, bitShift ); break; default: m_boUnsupportedPixelFormat = true; break; } #else for( int i = 0; i <= 8; i++ ) { for( int j = 0; j <= 8; j++ ) { for( int k = 0; k <= 8; k++ ) { p->Set( saveAssign( 1 << k, 0, 255 ), saveAssign( 1 << j, 0, 255 ), saveAssign( 1 << i, 0, 255 ) ); ++p; } } } #endif // #ifndef TEST_VECTOR_SCOPE UpdateAnalysisOutput( boAOIChanged ); } //----------------------------------------------------------------------------- void VectorScopeCanvas::UpdateGrid( void ) //----------------------------------------------------------------------------- { if( m_pNumericalDisplay ) { unsigned int rowCount = static_cast<unsigned int>( m_pNumericalDisplay->GetTable()->GetNumberRows() ); if( rowCount < ( m_valCount + 1 ) ) { m_pNumericalDisplay->AppendRows( m_valCount + 1 - rowCount ); } else if( rowCount > ( m_valCount + 1 ) ) { m_pNumericalDisplay->DeleteRows( rowCount - 1, rowCount - ( m_valCount + 1 ) ); } } PlotCanvasImageAnalysis::UpdateGrid(); }
[ "zheng.rong.14@gmail.com" ]
zheng.rong.14@gmail.com
d6d0b48d81c51cba442ba5f56b219e6eebf73010
22cfcbfee89e491971d855ba4ed7e3eb12c5c9f0
/Source/WorldServer/SceneRegMgr.h
ccfac06ddd419283c75c0b96b2559378a03b28db
[]
no_license
huangzuduan/HMX-Server
dac6a9f7cc40fa169a64605a6a365b49a7bb084c
13a28e243dccb44dd06d45dbddd35541a994d713
refs/heads/master
2018-10-31T23:32:38.788380
2018-09-26T11:14:53
2018-09-26T11:14:53
79,187,627
29
26
null
null
null
null
GB18030
C++
false
false
1,304
h
#ifndef __SCENE_INFO_MANAGER_H_ #define __SCENE_INFO_MANAGER_H_ #include "SrvEngine.h" #include "Single.h" /*------------------------------------------------------------------- * @Brief : 本类记录场景服的信息,记录场景服在WS上注册了哪些场景ID * 同时 * @Author:hzd 2015:11:18 *------------------------------------------------------------------*/ /* 场景动态信息 id=场景ID */ class SceneReg : public zEntry { public: SceneReg() { id = tempid = sessid = mapid = 0; } inline uint64_t GetID(){ return id; } inline uint64_t GetTempID(){ return tempid; } inline const std::string& GetName(){ return _entry_name; } public: uint64_t id; uint64_t tempid; uint64_t sessid; uint32_t mapid; }; /*-- 场景管理器 */ class SceneRegMgr : protected zEntryMgr< zEntryID<0> >,public Single<SceneRegMgr> { protected: friend class Single<SceneRegMgr>; SceneRegMgr(); ~SceneRegMgr(); public: SceneReg* CreateObj(); void DestroyObj(SceneReg* obj); bool add(SceneReg* scene); void remove(SceneReg* scene); SceneReg* get(int64_t id); SceneReg* getBymapid(int32_t mapid);// 获得第一个scene(通常也只有一个scene) SceneReg* getFreeBymapid(int32_t mapid); // 获得比较空闲的场景 private: zObjPool<SceneReg> objpool; }; #endif
[ "huangzuduan@qq.com" ]
huangzuduan@qq.com
eb428683e07c0afe788c21db30cc92da3a6a0b18
97c8cef39b59355f92183f006d1cae80101c4e1d
/projekt_c++_roboczy/Turtle.h
ccb3ae8e9a7e6aa8e58db3adf39db21e0aed4dd8
[]
no_license
polom01/wirtualWorld
446379f933aca09ac9fc61539315f9725065b220
b670606bb717c6a6807bcf8d2f78673e5cb70f11
refs/heads/master
2020-03-21T15:32:40.453298
2018-06-26T09:54:43
2018-06-26T09:54:43
138,718,605
0
0
null
null
null
null
UTF-8
C++
false
false
686
h
#pragma once #pragma once #include"Animal.h" #include<iostream> #include <cstdlib> #include <ctime> class Turtle : public Animal { public: Turtle(World *wo, int x, int y) { this->Set_World(wo); this->Set_initiative(1); this->Set_force(2); this->SetYposition(y); this->SetXposition(x); this->type = 'Z'; this->time = this->GetTime(); std::cout << "zolw sie urodzil :)" << std::endl; } Animal* createMe(World *world, int x, int y) override { Animal *newOne = new Turtle(world, x, y); return newOne; } void Action() override { int number = (std::rand() % 4) + 0; if (number == 0) { Animal::Action(); } } };
[ "noreply@github.com" ]
noreply@github.com
cccf98095e409c7c8a101335bf182511084d4fc5
0841b965ef16edab738c260e2bb46dec5a44857d
/collections/hashmap/hashmap.h
8978e89226da2a7f860c6e0a1bcb93dbf9dff264
[]
no_license
ant512/WoopsiExtras
b73e399ebb3bd7685587e7e8b6051d336989354a
45ea469a22827b737a361b5a5f73cbeffe2974c3
refs/heads/master
2021-01-08T22:13:16.196976
2010-09-03T08:28:31
2010-09-03T08:28:31
242,157,454
0
0
null
null
null
null
UTF-8
C++
false
false
5,975
h
#ifndef _HASHMAP_H_ #define _HASHMAP_H_ // Hashmap table size *must* be a power of two as it is used as a bitmask in the hash function const s32 HASHMAP_DEFAULT_SIZE = 32; template <class T> class HashMapIterator; /** * Struct representing a single item in a hash map bucket. */ template <class T> struct HashMapBucket { T data; const char* key; HashMapBucket<T>* next; HashMapBucket<T>* previous; }; /** * Class providing a hashmap. A hashmap is a collection data structure storing key/value pairs. * This implementation uses chaining, or linked lists of buckets, to handle hash collisions. * The hashmap does not resize to contain more data. As more data is added, the linked lists * will automatically grow. This means that the hashtable will gradually degrade in performance * as it fills up. * Uses Bob Jenkins' one-at-a-time hash function from Wikipedia. */ template <class T> class HashMap { public: /** * Constructor. */ HashMap(); /** * Destructor. */ ~HashMap(); /** * Get the number of items in the hashmap. * @return The number of items in the hashmap. */ const s32 size() const; /** * Add a key/value pair into the hashmap. * @param key The unique key for this value. * @param value The value to add to the hashmap. */ void add(const char* key, const T &value); /** * Get the value at the specified key. * @param key The key of the item to return. */ T item(const char* key); /** * Erase a single value at the specified key. * @param key The key of the item to erase. */ void erase(const char* key); /** * Check if the map has any data. * @return True if the map is empty. */ bool empty(); /** * Remove all data. */ void clear(); /** * Get an iterator for this hashmap. * @return An iterator for the hashmap. */ HashMapIterator<T>* getIterator(); private: friend class HashMapIterator<T>; HashMapBucket<T>** _data; s32 _size; s32 _reservedSize; /** * Get the hash of the supplied key. * @param key The key to find the hash of. * @return The hash of the key */ const s32 getHash(const char* key) const; /** * Get the size of the array. * @return The size of the array. */ const s32 reservedSize() const; }; template <class T> HashMap<T>::HashMap() { _reservedSize = HASHMAP_DEFAULT_SIZE; _data = new HashMapBucket<T>*[_reservedSize]; _size = 0; // Initialise the array for (s32 i = 0; i < _reservedSize; i++) { _data[i] = NULL; } } template <class T> HashMap<T>::~HashMap() { clear(); // Delete main array delete [] _data; } template <class T> const s32 HashMap<T>::size() const { return _size; } template <class T> const s32 HashMap<T>::reservedSize() const { return _reservedSize; } template <class T> void HashMap<T>::add(const char* key, const T &value) { // Get hash for this key s32 hash = getHash(key); // Create bucket HashMapBucket<T>* bucket = new HashMapBucket<T>; bucket->data = value; bucket->key = key; bucket->previous = NULL; bucket->next = NULL; // Remember we've added a new item _size++; // Attempt to insert into empty bucket if (_data[hash] == NULL) { _data[hash] = bucket; return; } // Insert bucket into start of list bucket->next = _data[hash]; _data[hash]->previous = bucket; _data[hash] = bucket; } template <class T> T HashMap<T>::item(const char* key) { // Get hash for this key s32 hash = getHash(key); // Locate item HashMapBucket<T>* bucket = _data[hash]; // Have we found the item? while ((bucket->next != NULL) && (strcmp(bucket->key, key))) { bucket = bucket->next; } return bucket->data; } template <class T> void HashMap<T>::erase(const char* key) { // Get hash for this key s32 hash = getHash(key); // Locate item HashMapBucket<T>* bucket = _data[hash]; // Have we found the item? while ((bucket->next != NULL) && (strcmp(bucket->key, key))) { bucket = bucket->next; } // Is the item the only one in its slot? if ((bucket->previous == NULL) && (bucket->next == NULL)) { // Only item in the slot, so just kill it delete _data[hash]; _data[hash] = NULL; _size--; return; } // Is the item the first one in the list? if ((bucket->previous == NULL) && (bucket->next != NULL)) { // Item is first in list _data[hash] = bucket->next; bucket->next->previous = NULL; // Delete the item delete bucket; _size--; return; } // Is the item the last one in the list? if (bucket->next == NULL) { // Item last in list bucket->previous->next = NULL; // Delete the item delete bucket; _size--; return; } // Remove item from the middle of the list bucket->next->previous = bucket->previous; bucket->previous->next = bucket->next; delete bucket; _size--; } template <class T> void HashMap<T>::clear() { // Loop through all array slots deleting all buckets for (s32 i = 0; i < _reservedSize; i++) { HashMapBucket<T>* bucket = _data[i]; HashMapBucket<T>* nextBucket = NULL; // Delete all buckets in this slot while (bucket != NULL) { nextBucket = bucket->next; delete bucket; bucket = nextBucket; } _data[i] = NULL; } _size = 0; } template <class T> bool HashMap<T>::empty() { return (_size == 0); } template <class T> const s32 HashMap<T>::getHash(const char* key) const { s32 hash = 0; char ch; while(*key) { ch = *key++; hash += ch; hash += (ch << 10); hash ^= (ch >> 6); } hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash & (_reservedSize - 1); } template <class T> HashMapIterator<T>* HashMap<T>::getIterator() { return new HashMapIterator<T>(this); } #endif
[ "devnull@localhost" ]
devnull@localhost
97d9e10d8c0598b9aa66c412d05bedf5cf7bc5d7
135407d6ba9c103aafa1a1d94210f057f8e25d21
/WorldEditor/WorldEditor/NewImageDlg.h
bae0ccbcb8aa09842f9006b47a88b9b35d4d3fe2
[ "BSD-3-Clause" ]
permissive
DebugBSD/WorldEditor
1e8088856b3954864cd80141924ac912582e3fb9
b68b80c71489316adecd33831aaf6a686d81a61b
refs/heads/main
2023-04-12T02:48:01.521028
2023-04-06T16:27:55
2023-04-06T16:27:55
314,997,766
0
0
null
null
null
null
UTF-8
C++
false
false
777
h
#pragma once #include <wx/dialog.h> class NewImageDlg : public wxDialog { public: enum { ID_BUTTON_SAVE_COPY_AS = wxID_HIGHEST + 1, ID_HEIGHT_TEXTCTRL, ID_WIDTH_TEXTCTRL }; NewImageDlg(); wxSize GetSizeOfCanvas() { return wxSize{(int)m_Width, (int)m_Height}; } private: unsigned int m_Width; unsigned int m_Height; class wxButton* m_pOKButton; class wxButton* m_pCancelButton; class wxTextCtrl* m_pWidthTextCtrl; class wxTextCtrl* m_pHeightTextCtrl; void EnableButton(void); void OnOK(wxCommandEvent &event); void OnCancel(wxCommandEvent &event); void OnTextHeightChanged(wxCommandEvent &event); void OnTextWidthChanged(wxCommandEvent& event); wxDECLARE_EVENT_TABLE(); };
[ "debugbsd@gmail.com" ]
debugbsd@gmail.com
4214099e6bdbdcd638a10ba6e8975a47af50384d
13d7f1f9e9fa301b26e182d046ec10feac1c537b
/test.cpp
300647960d41670f02c2f27396f10666876df25d
[]
no_license
yukun89/leetcode
536d06c23c4350caeb98dc17429f1df63e8f075a
b24f8658a49d70e3134255c311225bf5b601334b
refs/heads/master
2020-04-13T22:59:36.399970
2018-12-29T08:48:09
2018-12-29T08:48:09
163,494,239
0
0
null
null
null
null
UTF-8
C++
false
false
285
cpp
#include <string.h> #include <stdio.h> int main(){ char s[] = "a,b*c,d"; const char *sep = ",*"; //可按多个字符来分割 char *p; p = strtok(s, sep); while(p){ printf("%s ", p); p = strtok(NULL, sep); } printf("\n"); return 0; }
[ "huangyukun2012@gmail.com" ]
huangyukun2012@gmail.com
1d1bf43317db613a606c7d6abf28e205ff6bdce2
f3001cd56567b121736343b480a1abf9cba1cd52
/EncoderTests/iar/main.cpp
6c93c50e34bf30e29389e2eded7af07f1e52a758
[]
no_license
cjsatuforc/AvrProjects
257f0594740b215ff2db2abaa79ec718cd14d647
a9f70a87a28e426ee4a558ca5ddc198f97a1ebdb
refs/heads/master
2020-04-13T19:00:06.609001
2011-03-18T16:01:42
2011-03-18T16:01:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,823
cpp
#include <ioavr.h> #include <stdint.h> static uint8_t EncState=0; static volatile uint16_t EncValue=0; #if 0 #pragma inline=forced inline static void EncoderScan(void) { uint8_t newValue = PINC & 0x03; uint8_t fullState = newValue | EncState << 2; switch(fullState) { case 0x2: case 0x4: case 0xB: case 0xD: EncValue ++; break; case 0x1: case 0x7: case 0x8: case 0xE: EncValue --; break; } EncState = newValue; } #pragma vector=TIMER1_COMPA_vect __interrupt void TIMER1_COMPA() { EncoderScan(); } #else typedef unsigned EncValueType; enum{EncoderChannels = 8}; static volatile EncValueType EncoderValues[EncoderChannels]; static uint8_t _x1, _x2; static inline uint8_t Detect(uint8_t x1, uint8_t x2, uint8_t y1, uint8_t y2) { return (x2 ^ y1) & ~(x1 ^ y2); } inline uint8_t EncRead1(); inline uint8_t EncRead2(); #pragma inline=forced static inline void EncoderCapture() { uint8_t y1 = EncRead1(); uint8_t y2 = EncRead2(); uint8_t fwd = Detect(_x1, _x2, y1, y2); uint8_t back = Detect(_x2, _x1, y2, y1); _x1 = y1; _x2 = y2; volatile EncValueType * ptr = EncoderValues; for(uint8_t i = EncoderChannels; i; --i) { if(fwd & 1) (*ptr) ++; else if(back & 1) (*ptr) --; ptr++; fwd >>= 1; back >>= 1; } } #pragma inline=forced inline uint8_t EncRead1() { return PINC; } #pragma inline=forced inline uint8_t EncRead2() { return PIND; } #pragma vector=TIMER1_COMPA_vect __interrupt void TIMER1_COMPA() { EncoderCapture(); } #endif typedef void (* voidCall)(); int main() { //call ISR dirrectly for timing calculation voidCall func = (voidCall)TIMER1_COMPA; func(); while(1) { } return 0; }
[ "kchizhov@griddynamics.com" ]
kchizhov@griddynamics.com
b6371dfaa0c47ed5c4efe1db5ae502dc3857347a
4346b2d8e50996c66b9f1112792f3c80fc271b8a
/Event.hpp
cdc8fbb55123982ec3c9e4f0949f3b477e4b049b
[]
no_license
TsJennyfer/Calendar.cpp
3ba084780fdf5a702a8085914d6a43bc3ad8fd0d
14357feed832ded6aa84232cd9cb727246188620
refs/heads/master
2021-01-09T06:34:35.453757
2016-05-30T20:38:32
2016-05-30T20:38:32
59,889,964
0
0
null
null
null
null
UTF-8
C++
false
false
538
hpp
// // Event.hpp // OrganizerCpp // // Created by Yevheniia Tsapkova on 20/05/16. // Copyright © 2016 Yevheniia Tsapkova. All rights reserved. // #ifndef Event_hpp #define Event_hpp #include <iostream> using namespace std; class Event { public: Event () { } Event (string category, time_t date, int len, string activity) : category(category), date (date), len (len), activity (activity) { } string category; time_t date; int len; string activity; }; #endif /* Event_hpp */
[ "jn@Yevheniias-Mac-mini.local" ]
jn@Yevheniias-Mac-mini.local
0e950f7f08df08e847766927f54b046f814fdf19
e4355967555857fd536787dce39ca30426ffa702
/V5.1/v5/系统模块/全局定义/Module.h
7f8de1aa865e29711cee9c07e7266d3cb2f5e836
[]
no_license
herox25000/oathx-ogrex-editor
f0fd6044f8065db9cb50a80376e52f502734e877
f645c7997f27e11a9063a0d352accd98a474cef1
refs/heads/master
2020-12-24T14:35:34.912603
2013-08-24T06:20:06
2013-08-24T06:20:06
32,935,652
6
9
null
null
null
null
GB18030
C++
false
false
10,588
h
#ifndef MODULE_HEAD_FILE #define MODULE_HEAD_FILE ////////////////////////////////////////////////////////////////////////////////// //模块接口 #define VER_IUnknownEx INTERFACE_VERSION(1,1) static const GUID IID_IUnknownEx={0x5feec21e,0xdbf3,0x46f0,0x9f,0x57,0xd1,0xcd,0x71,0x1c,0x46,0xde}; //基础接口 interface IUnknownEx { //释放对象 virtual VOID Release()=NULL; //接口查询 virtual VOID * QueryInterface(REFGUID Guid, DWORD dwQueryVer)=NULL; }; ////////////////////////////////////////////////////////////////////////////////// //版本比较 //产品版本 #define BULID_VER 0 //授权版本 #define PRODUCT_VER 6 //产品版本 //接口版本 #define INTERFACE_VERSION(cbMainVer,cbSubVer) \ (DWORD)( \ (((BYTE)(PRODUCT_VER))<<24)+ \ (((BYTE)(cbMainVer))<<16)+ \ ((BYTE)(cbSubVer)<<8))+ \ ((BYTE)(BULID_VER)) //模块版本 #define PROCESS_VERSION(cbMainVer,cbSubVer,cbBuildVer) \ (DWORD)( \ (((BYTE)(PRODUCT_VER))<<24)+ \ (((BYTE)(cbMainVer))<<16)+ \ ((BYTE)(cbSubVer)<<8)+ \ (BYTE)(cbBuildVer)) //产品版本 inline BYTE GetProductVer(DWORD dwVersion) { return ((BYTE *)&dwVersion)[3]; } //主要版本 inline BYTE GetMainVer(DWORD dwVersion) { return ((BYTE *)&dwVersion)[2]; } //次要版本 inline BYTE GetSubVer(DWORD dwVersion) { return ((BYTE *)&dwVersion)[1]; } //编译版本 inline BYTE GetBuildVer(DWORD dwVersion) { return ((BYTE *)&dwVersion)[0]; } //版本比较 inline bool InterfaceVersionCompare(DWORD dwQueryVer, DWORD dwInterfaceVer) { if (GetSubVer(dwQueryVer)>GetSubVer(dwInterfaceVer)) return false; if (GetMainVer(dwQueryVer)!=GetMainVer(dwInterfaceVer)) return false; if (GetBuildVer(dwQueryVer)!=GetBuildVer(dwInterfaceVer)) return false; if (GetProductVer(dwQueryVer)!=GetProductVer(dwInterfaceVer)) return false; return true; }; ////////////////////////////////////////////////////////////////////////////////// //内部接口查询 //查询接口 #define QUERYINTERFACE(Interface,Guid,dwQueryVer) \ if ((Guid==IID_##Interface)&&(InterfaceVersionCompare(dwQueryVer,VER_##Interface))) \ return static_cast<Interface *>(this); //查询接口 #define QUERYINTERFACE_IUNKNOWNEX(BaseInterface,Guid,dwQueryVer) \ if ((Guid==IID_IUnknownEx)&&(InterfaceVersionCompare(dwQueryVer,VER_IUnknownEx))) \ return static_cast<IUnknownEx *>(static_cast<BaseInterface *>(this)); ////////////////////////////////////////////////////////////////////////////////// //外部接口查询 //查询接口 #define QUERY_ME_INTERFACE(Interface) \ ((Interface *)QueryInterface(IID_##Interface,VER_##Interface)) //查询接口 #define QUERY_OBJECT_INTERFACE(Object,Interface) \ ((Interface *)Object.QueryInterface(IID_##Interface,VER_##Interface)) //查询接口 #define QUERY_OBJECT_PTR_INTERFACE(pObject,Interface) \ ((pObject==NULL)?NULL:((Interface *)pObject->QueryInterface(IID_##Interface,VER_##Interface))) ////////////////////////////////////////////////////////////////////////////////// //组件模板辅助模板 //组件创建函数 typedef VOID * (ModuleCreateProc)(REFGUID Gudi, DWORD dwInterfaceVer); //组件辅助类模板 template <typename IModeluInterface> class CTempldateHelper { //接口属性 public: REFGUID m_Guid; //接口标识 const DWORD m_dwVersion; //接口版本 //组件属性 public: CHAR m_szCreateProc[32]; //创建函数 TCHAR m_szModuleDllName[MAX_PATH]; //组件名字 //内核变量 public: HINSTANCE m_hDllInstance; //DLL 句柄 IModeluInterface * m_pIModeluInterface; //模块接口 //辅助变量 public: TCHAR m_szDescribe[128]; //错误描述 //函数定义 public: //构造函数 CTempldateHelper(REFGUID Guid, DWORD dwVersion); //构造函数 CTempldateHelper(REFGUID Guid, DWORD dwVersion, LPCTSTR pszModuleDll, LPCSTR pszCreateProc); //析构函数 virtual ~CTempldateHelper(); //管理函数 public: //释放组件 bool CloseInstance(); //创建函数 bool CreateInstance(); //配置函数 public: //创建信息 VOID SetModuleCreateInfo(LPCTSTR pszModuleDllName, LPCSTR pszCreateProc); //辅助函数 public: //获取错误 inline LPCTSTR GetErrorDescribe() const; //指针重载 inline IModeluInterface * operator->() const; //获取接口 inline IModeluInterface * GetInterface() const; }; ////////////////////////////////////////////////////////////////////////////////// // CTempldateHelper<IModeluInterface> 外联函数 //构造函数 template <typename IModeluInterface> CTempldateHelper<IModeluInterface>::CTempldateHelper(REFGUID Guid, DWORD dwVersion) : m_dwVersion(dwVersion), m_Guid(Guid) { //辅助变量 m_szDescribe[0]=0; //内核信息 m_hDllInstance=NULL; m_pIModeluInterface=NULL; //组件属性 ZeroMemory(m_szCreateProc,sizeof(m_szCreateProc)); ZeroMemory(m_szModuleDllName,sizeof(m_szModuleDllName)); return; } //构造函数 template <typename IModeluInterface> CTempldateHelper<IModeluInterface>::CTempldateHelper(REFGUID Guid, DWORD dwVersion, LPCTSTR pszModuleDll, LPCSTR pszCreateProc) : m_dwVersion(dwVersion), m_Guid(Guid) { //辅助变量 m_szDescribe[0]=0; //内核信息 m_hDllInstance=NULL; m_pIModeluInterface=NULL; //组件属性 lstrcpynA(m_szCreateProc,pszCreateProc,CountArray(m_szCreateProc)); lstrcpyn(m_szModuleDllName,pszModuleDll,CountArray(m_szModuleDllName)); return; } //析构函数 template <typename IModeluInterface> CTempldateHelper<IModeluInterface>::~CTempldateHelper() { CloseInstance(); } //创建组件 template <typename IModeluInterface> bool CTempldateHelper<IModeluInterface>::CreateInstance() { //释放组件 CloseInstance(); //创建组件 try { //效验参数 ASSERT(m_szCreateProc[0]!=0); ASSERT(m_szModuleDllName[0]!=0); //加载模块 m_hDllInstance=AfxLoadLibrary(m_szModuleDllName); if (m_hDllInstance==NULL) { _sntprintf(m_szDescribe,CountArray(m_szDescribe),TEXT("“%s”模块加载失败"),m_szModuleDllName); return false; } //寻找函数 ModuleCreateProc * CreateProc=(ModuleCreateProc *)GetProcAddress(m_hDllInstance,m_szCreateProc); if (CreateProc==NULL) { _sntprintf(m_szDescribe,CountArray(m_szDescribe),TEXT("找不到组件创建函数“%s”"),m_szCreateProc); return false; } //创建组件 m_pIModeluInterface=(IModeluInterface *)CreateProc(m_Guid,m_dwVersion); if (m_pIModeluInterface==NULL) { _sntprintf(m_szDescribe,CountArray(m_szDescribe),TEXT("调用函数“%s”生成对象失败"),m_szCreateProc); return false; } } catch (LPCTSTR pszError) { _sntprintf(m_szDescribe,CountArray(m_szDescribe),TEXT("由于“%s”,组件创建失败"),pszError); return false; } catch (...) { _sntprintf(m_szDescribe,CountArray(m_szDescribe),TEXT("组件创建函数“%s”产生未知异常错误,组件创建失败"),m_szCreateProc); return false; } return true; } //释放组件 template <typename IModeluInterface> bool CTempldateHelper<IModeluInterface>::CloseInstance() { //设置变量 m_szDescribe[0]=0; //销毁对象 if (m_pIModeluInterface!=NULL) { m_pIModeluInterface->Release(); m_pIModeluInterface=NULL; } //释放 DLL if (m_hDllInstance!=NULL) { AfxFreeLibrary(m_hDllInstance); m_hDllInstance=NULL; } return true; } //创建信息 template <typename IModeluInterface> VOID CTempldateHelper<IModeluInterface>::SetModuleCreateInfo(LPCTSTR pszModuleDllName, LPCSTR pszCreateProc) { //设置信息 lstrcpynA(m_szCreateProc,pszCreateProc,CountArray(m_szCreateProc)); lstrcpyn(m_szModuleDllName,pszModuleDllName,CountArray(m_szModuleDllName)); return; } ////////////////////////////////////////////////////////////////////////////////// // CTempldateHelper<IModeluInterface> 内联函数 //获取描述 template <typename IModeluInterface> inline LPCTSTR CTempldateHelper<IModeluInterface>::GetErrorDescribe() const { return m_szDescribe; } //指针重载 template <typename IModeluInterface> inline IModeluInterface * CTempldateHelper<IModeluInterface>::operator->() const { return GetInterface(); } //获取接口 template <typename IModeluInterface> inline IModeluInterface * CTempldateHelper<IModeluInterface>::GetInterface() const { return m_pIModeluInterface; } ////////////////////////////////////////////////////////////////////////////////// //组件辅助宏 //组件创建函数 #define DECLARE_CREATE_MODULE(OBJECT_NAME) \ extern "C" __declspec(dllexport) VOID * Create##OBJECT_NAME(REFGUID Guid, DWORD dwInterfaceVer) \ { \ C##OBJECT_NAME * p##OBJECT_NAME=NULL; \ try \ { \ p##OBJECT_NAME=new C##OBJECT_NAME(); \ if (p##OBJECT_NAME==NULL) throw TEXT("创建失败"); \ VOID * pObject=p##OBJECT_NAME->QueryInterface(Guid,dwInterfaceVer); \ if (pObject==NULL) throw TEXT("接口查询失败"); \ return pObject; \ } \ catch (...) {} \ SafeDelete(p##OBJECT_NAME); \ return NULL; \ } //组件辅助类宏 #define DECLARE_MODULE_DYNAMIC(OBJECT_NAME) \ class C##OBJECT_NAME##Helper : public CTempldateHelper<I##OBJECT_NAME> \ { \ public: \ C##OBJECT_NAME##Helper() : CTempldateHelper<I##OBJECT_NAME>(IID_I##OBJECT_NAME,VER_I##OBJECT_NAME) { } \ }; //组件辅助类宏 #define DECLARE_MODULE_HELPER(OBJECT_NAME,MODULE_DLL_NAME,CREATE_FUNCTION_NAME) \ class C##OBJECT_NAME##Helper : public CTempldateHelper<I##OBJECT_NAME> \ { \ public: \ C##OBJECT_NAME##Helper() : CTempldateHelper<I##OBJECT_NAME>(IID_I##OBJECT_NAME, \ VER_I##OBJECT_NAME,MODULE_DLL_NAME,CREATE_FUNCTION_NAME) { } \ }; ////////////////////////////////////////////////////////////////////////////////// #endif
[ "ydxl2011@yahoo.cn@a113e17c-5e0c-ebba-c532-3ad10810a225" ]
ydxl2011@yahoo.cn@a113e17c-5e0c-ebba-c532-3ad10810a225
712426abafa9d850992ed1bf3a570bc5a12c737d
6c00891640c630dbb1201786364b52f6caaccb18
/Main_Arduino_Programs/MainArduino_FirstTest_ConcVIVI/MainArduino_FirstTest_ConcVIVI.ino
511d8314aae82699d0f0e3ad1e92ba0c146c1834
[ "MIT" ]
permissive
ToshiEAB/Raspberry-Pi
46aad8a9b2ace44ca7d39c578a28d7d20c6c3445
0cf0660d79398c971e252912f51b2f101562f079
refs/heads/master
2021-07-11T15:54:23.070961
2021-04-13T07:29:19
2021-04-13T07:29:19
86,639,960
0
0
null
null
null
null
UTF-8
C++
false
false
753
ino
/* * Copyright: Toshikazu * * <Description> * This program is for testing the latency from a response * to the reinforcer it produces in a concurrent VI VI schedule. * */ byte Response1 = 2; byte Relay = 3; byte Response2 = 4; void setup() { Serial.begin(9600); pinMode(Response1, INPUT_PULLUP); pinMode(Response2, INPUT_PULLUP); pinMode(Relay, OUTPUT); digitalWrite(Relay, LOW); } void loop() { if (Serial.available() > 0) { char Event = Serial.read(); switch (Event) { case 'r': digitalWrite(Relay, HIGH); delay(20); digitalWrite(Relay, LOW); delay(20); break; } } Serial.println(String(digitalRead(Response1))+String(digitalRead(Response2))); delay(4); }
[ "noreply@github.com" ]
noreply@github.com
8b5360ff255dde747b08fa699772fc06052ce7c0
a301cf83fd30da1d0fc74e4828c960f82d33e836
/src/Distributed_libraries/dubins.cpp
795c6f5838558f24d70e62cb2bcf47e0c01f72a5
[]
no_license
yangfuyuan/highlevel_planner
4eea93823ba2709103854be339edda7bba91633e
7890a21d5b8268045f9067328ab6fdfdf3da7d5d
refs/heads/master
2020-12-27T09:32:27.713579
2014-08-07T23:49:15
2014-08-07T23:49:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,362
cpp
// Copyright (c) 2008-2014, Andrew Walker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #include "dubins.h" #include <math.h> #include <assert.h> #define EPSILON (10e-10) #define LSL (0) #define LSR (1) #define RSL (2) #define RSR (3) #define RLR (4) #define LRL (5) // The three segment types a path can be made up of #define L_SEG (0) #define S_SEG (1) #define R_SEG (2) // The segment types for each of the Path types const int DIRDATA[][3] = { { L_SEG, S_SEG, L_SEG }, { L_SEG, S_SEG, R_SEG }, { R_SEG, S_SEG, L_SEG }, { R_SEG, S_SEG, R_SEG }, { R_SEG, L_SEG, R_SEG }, { L_SEG, R_SEG, L_SEG } }; DubinsWord dubins_words[] = { dubins_LSL, dubins_LSR, dubins_RSL, dubins_RSR, dubins_RLR, dubins_LRL, }; #define UNPACK_INPUTS(alpha, beta) \ double sa = sin(alpha); \ double sb = sin(beta); \ double ca = cos(alpha); \ double cb = cos(beta); \ double c_ab = cos(alpha - beta); \ #define PACK_OUTPUTS(outputs) \ outputs[0] = t; \ outputs[1] = p; \ outputs[2] = q; /** * Floating point modulus suitable for rings * * fmod doesn't behave correctly for angular quantities, this function does */ double fmodr( double x, double y) { return x - y*floor(x/y); } double mod2pi( double theta ) { return fmodr( theta, 2 * M_PI ); } int dubins_init_normalised( double alpha, double beta, double d, DubinsPath* path) { double best_cost = INFINITY; int best_word; int i; best_word = -1; for( i = 0; i < 6; i++ ) { double params[3]; int err = dubins_words[i](alpha, beta, d, params); if(err == EDUBOK) { double cost = params[0] + params[1] + params[2]; if(cost < best_cost) { best_word = i; best_cost = cost; path->param[0] = params[0]; path->param[1] = params[1]; path->param[2] = params[2]; path->type = i; } } } if(best_word == -1) { return EDUBNOPATH; } path->type = best_word; return EDUBOK; } int dubins_init( double* q0, double* q1, double rho, DubinsPath* path ) { int i; double dx = q1[0] - q0[0]; double dy = q1[1] - q0[1]; double D = sqrt( dx * dx + dy * dy ); double d = D / rho; if( rho <= 0. ) { return EDUBBADRHO; } double theta = mod2pi(atan2( dy, dx )); double alpha = mod2pi(q0[2] - theta); double beta = mod2pi(q1[2] - theta); for( i = 0; i < 3; i ++ ) { path->qi[i] = q0[i]; } path->rho = rho; return dubins_init_normalised( alpha, beta, d, path ); } int dubins_LSL( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double tmp0 = d+sa-sb; double p_squared = 2 + (d*d) -(2*c_ab) + (2*d*(sa - sb)); if( p_squared < 0 ) { return EDUBNOPATH; } double tmp1 = atan2( (cb-ca), tmp0 ); double t = mod2pi(-alpha + tmp1 ); double p = sqrt( p_squared ); double q = mod2pi(beta - tmp1 ); PACK_OUTPUTS(outputs); return EDUBOK; } int dubins_RSR( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double tmp0 = d-sa+sb; double p_squared = 2 + (d*d) -(2*c_ab) + (2*d*(sb-sa)); if( p_squared < 0 ) { return EDUBNOPATH; } double tmp1 = atan2( (ca-cb), tmp0 ); double t = mod2pi( alpha - tmp1 ); double p = sqrt( p_squared ); double q = mod2pi( -beta + tmp1 ); PACK_OUTPUTS(outputs); return EDUBOK; } int dubins_LSR( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double p_squared = -2 + (d*d) + (2*c_ab) + (2*d*(sa+sb)); if( p_squared < 0 ) { return EDUBNOPATH; } double p = sqrt( p_squared ); double tmp2 = atan2( (-ca-cb), (d+sa+sb) ) - atan2(-2.0, p); double t = mod2pi(-alpha + tmp2); double q = mod2pi( -mod2pi(beta) + tmp2 ); PACK_OUTPUTS(outputs); return EDUBOK; } int dubins_RSL( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double p_squared = (d*d) -2 + (2*c_ab) - (2*d*(sa+sb)); if( p_squared< 0 ) { return EDUBNOPATH; } double p = sqrt( p_squared ); double tmp2 = atan2( (ca+cb), (d-sa-sb) ) - atan2(2.0, p); double t = mod2pi(alpha - tmp2); double q = mod2pi(beta - tmp2); PACK_OUTPUTS(outputs); return EDUBOK; } int dubins_RLR( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double tmp_rlr = (6. - d*d + 2*c_ab + 2*d*(sa-sb)) / 8.; if( fabs(tmp_rlr) > 1) { return EDUBNOPATH; } double p = mod2pi( 2*M_PI - acos( tmp_rlr ) ); double t = mod2pi(alpha - atan2( ca-cb, d-sa+sb ) + mod2pi(p/2.)); double q = mod2pi(alpha - beta - t + mod2pi(p)); PACK_OUTPUTS( outputs ); return EDUBOK; } int dubins_LRL( double alpha, double beta, double d, double* outputs ) { UNPACK_INPUTS(alpha, beta); double tmp_lrl = (6. - d*d + 2*c_ab + 2*d*(- sa + sb)) / 8.; if( fabs(tmp_lrl) > 1) { return EDUBNOPATH; } double p = mod2pi( 2*M_PI - acos( tmp_lrl ) ); double t = mod2pi(-alpha - atan2( ca-cb, d+sa-sb ) + p/2.); double q = mod2pi(mod2pi(beta) - alpha -t + mod2pi(p)); PACK_OUTPUTS( outputs ); return EDUBOK; } double dubins_path_length( DubinsPath* path ) { double length = 0.; length += path->param[0]; length += path->param[1]; length += path->param[2]; length = length * path->rho; return length; } int dubins_path_type( DubinsPath* path ) { return path->type; } void dubins_segment( double t, double qi[3], double qt[3], int type) { assert( type == L_SEG || type == S_SEG || type == R_SEG ); if( type == L_SEG ) { qt[0] = qi[0] + sin(qi[2]+t) - sin(qi[2]); qt[1] = qi[1] - cos(qi[2]+t) + cos(qi[2]); qt[2] = qi[2] + t; } else if( type == R_SEG ) { qt[0] = qi[0] - sin(qi[2]-t) + sin(qi[2]); qt[1] = qi[1] + cos(qi[2]-t) - cos(qi[2]); qt[2] = qi[2] - t; } else if( type == S_SEG ) { qt[0] = qi[0] + cos(qi[2]) * t; qt[1] = qi[1] + sin(qi[2]) * t; qt[2] = qi[2]; } } int dubins_path_sample( DubinsPath* path, double t, double q[3] ) { if( t < 0 || t >= dubins_path_length(path) ) { // error, parameter out of bounds return EDUBPARAM; } // tprime is the normalised variant of the parameter t double tprime = t / path->rho; // In order to take rho != 1 into account this function needs to be more complex // than it would be otherwise. The transformation is done in five stages. // // 1. translate the components of the initial configuration to the origin // 2. generate the target configuration // 3. transform the target configuration // scale the target configuration // translate the target configration back to the original starting point // normalise the target configurations angular component // The translated initial configuration double qi[3] = { 0, 0, path->qi[2] }; // Generate the target configuration const int* types = DIRDATA[path->type]; double p1 = path->param[0]; double p2 = path->param[1]; double q1[3]; // end-of segment 1 double q2[3]; // end-of segment 2 dubins_segment( p1, qi, q1, types[0] ); dubins_segment( p2, q1, q2, types[1] ); if( tprime < p1 ) { dubins_segment( tprime, qi, q, types[0] ); } else if( tprime < (p1+p2) ) { dubins_segment( tprime-p1, q1, q, types[1] ); } else { dubins_segment( tprime-p1-p2, q2, q, types[2] ); } // scale the target configuration, translate back to the original starting point q[0] = q[0] * path->rho + path->qi[0]; q[1] = q[1] * path->rho + path->qi[1]; q[2] = mod2pi(q[2]); return 0; } int dubins_path_sample_many( DubinsPath* path, DubinsPathSamplingCallback cb, double stepSize, void* user_data ) { double x = 0.0; double length = dubins_path_length(path); while( x < length ) { double q[3]; dubins_path_sample( path, x, q ); int retcode = cb(q, x, user_data); if( retcode != 0 ) { return retcode; } x += stepSize; } return 0; } int dubins_path_endpoint( DubinsPath* path, double q[3] ) { // TODO - introduce a new constant rather than just using EPSILON return dubins_path_sample( path, dubins_path_length(path) - EPSILON, q ); } int dubins_extract_subpath( DubinsPath* path, double t, DubinsPath* newpath ) { // calculate the true parameter double tprime = t / path->rho; // copy most of the data newpath->qi[0] = path->qi[0]; newpath->qi[1] = path->qi[1]; newpath->qi[2] = path->qi[2]; newpath->rho = path->rho; newpath->type = path->type; // fix the parameters newpath->param[0] = fmin( path->param[0], tprime ); newpath->param[1] = fmin( path->param[1], tprime - newpath->param[0]); newpath->param[2] = fmin( path->param[2], tprime - newpath->param[0] - newpath->param[1]); return 0; }
[ "stefanjorgensen@socrates.ern.nps.edu" ]
stefanjorgensen@socrates.ern.nps.edu
ab4451226c728903284c6e2206278cc98b51922a
0b66e8133c28fd50e2ffddba741710bdc7756cb4
/99.WildPlayground/199. Binary Tree Right Side View.cc
17eaf895ef897277696d93af923873e07f161277
[]
no_license
tonyxwz/leetcode
21abed951622ed3606fc89c580cd32cda7b84a2f
1b7d06e638c0ff278c62d3bae27076b0881b5fde
refs/heads/master
2023-04-05T07:10:18.342010
2021-04-13T11:45:58
2021-04-13T11:45:58
71,467,875
0
0
null
null
null
null
UTF-8
C++
false
false
841
cc
#include "leetcode.h" /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), * right(right) {} * }; */ class Solution { public: vector<int> rightSideView(TreeNode* root) { deque<TreeNode*> q; vector<int> ans; if (root) q.push_back(root); while (!q.empty()) { ans.push_back(q.back()->val); int n = q.size(); while (n--) { auto x = q.front(); q.pop_front(); if (x->left) q.push_back(x->left); if (x->right) q.push_back(x->right); } } return ans; } };
[ "tonyxwz@yahoo.com" ]
tonyxwz@yahoo.com
e37df0714e32700e5af6e3f274b59d3a014fb762
6e6fa8fd9524b2b0d78dabbf7ceddc6805c673a7
/seg-base/main.cpp
c6d425d3d53ca414008ff976d2053695920bc80d
[]
no_license
WillianJunior/doc-segToolsRev
25a5234917b7d4c5fca20b910d7da4e6b153d4ef
afad0a53ce024c12d86c0fdc97d11e63993576eb
refs/heads/master
2020-04-13T20:53:32.708999
2019-03-15T01:58:57
2019-03-15T01:58:57
163,442,347
0
0
null
null
null
null
UTF-8
C++
false
false
11,694
cpp
/* * RedBloodCell.cpp * * Created on: Jul 1, 2011 * Author: tcpan */ #include <iostream> #include "pixelsOps.hpp" #include <opencv2/opencv.hpp> #define CONTINUE 0 #define BACKGROUND 1 #define BACKGROUND_LIKELY 2 #define NO_CANDIDATES_LEFT 3 #define SUCCESS 4 #define INVALID_IMAGE 5 int segmentNuclei(const std::string& in, const std::string& out, int &compcount, int *&bbox, unsigned char blue, unsigned char green, unsigned char red, double T1, double T2, unsigned char G1, int minSize, int maxSize, unsigned char G2, int minSizePl, int minSizeSeg, int maxSizeSeg, int fillHolesConnectivity, int reconConnectivity, int watershedConnectivity); int main() { int *bbox = NULL; int compcount; unsigned char G1 = 80; unsigned char G2 = 40; int minSize = 2; int reconConnectivity = 8; double T2 = 7.5; int maxSize = 1000; int minSizePl = 5; int minSizeSeg = 2; unsigned char blue = 240; unsigned char green = 240; unsigned char red = 240; double T1 = 7.5; int maxSizeSeg = 1000; int fillHolesConnectivity = 8; int watershedConnectivity = 8; int ret = segmentNuclei("in.tiff", "out.tiff", compcount, bbox, blue, green, red, T1, T2, G1, minSize, maxSize, G2, minSizePl, minSizeSeg, maxSizeSeg, fillHolesConnectivity, reconConnectivity, watershedConnectivity); std::cout << "ret: " << ret << std::endl; return 0; } // cv::Mat HistologicalEntities::getRBC(const cv::Mat& img, double T1, double T2, // ::cciutils::SimpleCSVLogger *logger, ::cciutils::cv::IntermediateResultHandler *iresHandler) { // CV_Assert(img.channels() == 3); // std::vector<cv::Mat> bgr; // split(img, bgr); // return getRBC(bgr, T1, T2, logger, iresHandler); // } cv::Mat getRBC(const std::vector<cv::Mat>& bgr, double T1, double T2) { CV_Assert(bgr.size() == 3); std::cout.precision(5); cv::Size s = bgr[0].size(); cv::Mat bd(s, CV_32FC1); cv::Mat gd(s, bd.type()); cv::Mat rd(s, bd.type()); bgr[0].convertTo(bd, bd.type(), 1.0, FLT_EPSILON); bgr[1].convertTo(gd, gd.type(), 1.0, FLT_EPSILON); bgr[2].convertTo(rd, rd.type(), 1.0, 0.0); cv::Mat imR2G = rd / gd; cv::Mat imR2B = (rd / bd) > 1.0; cv::Mat bw1 = imR2G > T1; cv::Mat bw2 = imR2G > T2; cv::Mat rbc; if (countNonZero(bw1) > 0) { rbc = serial::bwselect<unsigned char>(bw2, bw1, 8) & imR2B; } else { rbc = cv::Mat::zeros(bw2.size(), bw2.type()); } return rbc; } // cv::Mat HistologicalEntities::getBackground(const cv::Mat& img, unsigned char blue, unsigned char green, unsigned char red, // ::cciutils::SimpleCSVLogger *logger, ::cciutils::cv::IntermediateResultHandler *iresHandler) { // CV_Assert(img.channels() == 3); // std::vector<cv::Mat> bgr; // split(img, bgr); // return getBackground(bgr, blue, green, red, logger, iresHandler); // } cv::Mat getBackground(const std::vector<cv::Mat>& bgr, unsigned char blue, unsigned char green, unsigned char red) { return (bgr[0] > blue) & (bgr[1] > green) & (bgr[2] > red); } // S1 int plFindNucleusCandidates(const cv::Mat& img, cv::Mat& seg_norbc, unsigned char blue, unsigned char green, unsigned char red, double T1, double T2, unsigned char G1, int minSize, int maxSize, unsigned char G2, int fillHolesConnectivity, int reconConnectivity) { std::vector<cv::Mat> bgr; split(img, bgr); cv::Mat background = getBackground(bgr, blue, green, red); int bgArea = countNonZero(background); float ratio = (float)bgArea / (float)(img.size().area()); if (ratio >= 0.99) { return BACKGROUND; } else if (ratio >= 0.9) { return BACKGROUND_LIKELY; } cv::Mat rbc = getRBC(bgr, T1, T2); int rbcPixelCount = countNonZero(rbc); cv::Mat rc = serial::invert<unsigned char>(bgr[2]); cv::Mat rc_open(rc.size(), rc.type()); //cv::Mat disk19 = getStructuringElement(MORPH_ELLIPSE, Size(19,19)); // structuring element is not the same between matlab and opencv. // using the one from matlab explicitly.... // (for 4, 6, and 8 connected, they are approximations). unsigned char disk19raw[361] = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}; std::vector<unsigned char> disk19vec(disk19raw, disk19raw+361); cv::Mat disk19(disk19vec); disk19 = disk19.reshape(1, 19); rc_open = serial::morphOpen<unsigned char>(rc, disk19); cv::Mat rc_recon = serial::imreconstruct<unsigned char>(rc_open, rc, reconConnectivity); cv::Mat diffIm = rc - rc_recon; int rc_openPixelCount = countNonZero(rc_open); // it is now a parameter cv::Mat diffIm2 = diffIm > G1; cv::Mat bw1 = serial::imfillHoles<unsigned char>(diffIm2, true, fillHolesConnectivity); int compcount2; cv::Mat bw1_t = serial::bwareaopen2(bw1, false, true, minSize, maxSize, 8, compcount2); bw1.release(); if (compcount2 == 0) { return NO_CANDIDATES_LEFT; } // It is now a parameter cv::Mat bw2 = diffIm > G2; seg_norbc = serial::bwselect<unsigned char>(bw2, bw1_t, 8); seg_norbc = seg_norbc & (rbc == 0); return CONTINUE; } // A4 int plSeparateNuclei(const cv::Mat& img, const cv::Mat& seg_open, cv::Mat& seg_nonoverlap, int minSizePl, int watershedConnectivity) { // bwareaopen is done as a area threshold. int compcount2; cv::Mat seg_big_t = serial::bwareaopen2(seg_open, false, true, minSizePl, std::numeric_limits<int>::max(), 8, compcount2); cv::Mat disk3 = getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3,3)); cv::Mat seg_big = cv::Mat::zeros(seg_big_t.size(), seg_big_t.type()); dilate(seg_big_t, seg_big, disk3); // distance transform: matlab code is doing this: // invert the image so nuclei candidates are holes // compute the distance (distance of nuclei pixels to background) // negate the distance. so now background is still 0, but nuclei pixels have negative distances // set background to -inf // really just want the distance map. CV computes distance to 0. // background is 0 in output. // then invert to create basins cv::Mat dist(seg_big.size(), CV_32FC1); // opencv: compute the distance to nearest zero // matlab: compute the distance to the nearest non-zero distanceTransform(seg_big, dist, CV_DIST_L2, CV_DIST_MASK_PRECISE); double mmin, mmax; minMaxLoc(dist, &mmin, &mmax); // invert and shift (make sure it's still positive) dist = - dist; // appears to work better this way. // then set the background to -inf and do imhmin // appears to work better with -inf as background cv::Mat distance(dist.size(), dist.type(), -std::numeric_limits<float>::max()); dist.copyTo(distance, seg_big); // then do imhmin. (prevents small regions inside bigger regions) cv::Mat distance2 = serial::imhmin<float>(distance, 1.0f, 8); cv::Mat nuclei = cv::Mat::zeros(img.size(), img.type()); img.copyTo(nuclei, seg_big); // watershed in openCV requires labels. input foreground > 0, 0 is background // critical to use just the nuclei and not the whole image - else get a ring surrounding the regions. cv::Mat watermask = serial::watershed2(nuclei, distance2, watershedConnectivity); // MASK approach seg_nonoverlap = cv::Mat::zeros(seg_big.size(), seg_big.type()); seg_big.copyTo(seg_nonoverlap, (watermask >= 0)); return CONTINUE; } int segmentNuclei(const cv::Mat& img, cv::Mat& output, int &compcount, int *&bbox, unsigned char blue, unsigned char green, unsigned char red, double T1, double T2, unsigned char G1, int minSize, int maxSize, unsigned char G2, int minSizePl, int minSizeSeg, int maxSizeSeg, int fillHolesConnectivity, int reconConnectivity, int watershedConnectivity) { // image in BGR format if (!img.data) { std::cout << "bad BGR" << std::endl; return -1; } cv::Mat seg_norbc; int findCandidateResult = plFindNucleusCandidates(img, seg_norbc, blue, green, red, T1, T2, G1, minSize, maxSize, G2, fillHolesConnectivity, reconConnectivity); if (findCandidateResult != CONTINUE) { std::cout << "bad candidates" << std::endl; return findCandidateResult; } cv::Mat seg_nohole = serial::imfillHoles<unsigned char>(seg_norbc, true, 4); cv::Mat disk3 = getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3,3)); cv::Mat seg_open = serial::morphOpen<unsigned char>(seg_nohole, disk3); cv::Mat seg_nonoverlap; int sepResult = plSeparateNuclei(img, seg_open, seg_nonoverlap, minSizePl, watershedConnectivity); if (sepResult != CONTINUE) { std::cout << "bad sepResult" << std::endl; return sepResult; } int compcount2; // MASK approach cv::Mat seg = serial::bwareaopen2(seg_nonoverlap, false, true, minSizeSeg, maxSizeSeg, 4, compcount2); if (compcount2 == 0) { std::cout << "no candidates" << std::endl; return NO_CANDIDATES_LEFT; } // don't worry about bwlabel. // MASK approach cv::Mat final = serial::imfillHoles<unsigned char>(seg, true, fillHolesConnectivity); // MASK approach output = serial::bwlabel2(final, 8, true); final.release(); ConnComponents cc; bbox = cc.boundingBox(output.cols, output.rows, (int *)output.data, 0, compcount); return SUCCESS; } int segmentNuclei(const std::string& in, const std::string& out, int &compcount, int *&bbox, unsigned char blue, unsigned char green, unsigned char red, double T1, double T2, unsigned char G1, int minSize, int maxSize, unsigned char G2, int minSizePl, int minSizeSeg, int maxSizeSeg, int fillHolesConnectivity, int reconConnectivity, int watershedConnectivity) { cv::Mat input = cv::imread(in); if (!input.data) { std::cout << "bad input img" << std::endl; return INVALID_IMAGE; } cv::Mat output; int status = segmentNuclei(input, output, compcount, bbox, blue, green, red, T1, T2, G1, minSize, maxSize, G2, minSizePl, minSizeSeg, maxSizeSeg, fillHolesConnectivity, reconConnectivity, watershedConnectivity); input.release(); if (status == SUCCESS) cv::imwrite(out, output); output.release(); return status; }
[ "guns945@gmail.com" ]
guns945@gmail.com
10dbe8e0f21e94a5e914ece84c4d50641f4e0640
473e3a896b1f1795fab052c5c9846112972920f1
/src/dmatter/config/config.cpp
52a5680fce3068118f6a59c8a842d065e799dacd
[ "MIT" ]
permissive
zzz-zzz-zz-zz/cpp-config
32127f50944cf33da37b1a38b9f9cf72a8cbde6f
d0ababe486e4a758a2333f23e5f9a66061612338
refs/heads/master
2020-03-26T12:27:11.551012
2018-08-15T19:15:38
2018-08-15T19:15:38
144,893,047
1
0
null
null
null
null
UTF-8
C++
false
false
12,875
cpp
#include "dmatter/config/config.hpp" namespace dmatter { Config::Config(const std::string& path, ConfigFlags f) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG const char *prefix = "Config::Config(std::string, ConfigFlags) - "; #endif path_ = path; save_on_exit_ = f & ConfigFlags::SaveOnExit; if (f & ConfigFlags::LoadFromFile) { if (!try_load(path) && !(f & ConfigFlags::CreateNewFile)) { DMATTER_CONFIG_THROW(ConfigException(std::string("File \"") + path_ + std::string("\" cannot be opened"))); } } if (!ok_ && (f & ConfigFlags::CreateNewFile)) { std::ifstream i(path_); if (ok_ = !i.good()) { // Attempt to create new file std::ofstream o(path_); ok_ = o.is_open(); o.close(); if (ok_) { // Deleting empty created file because it's not what we want to save if (remove(path_.c_str()) != 0) { ok_ = false; DMATTER_CONFIG_THROW(ConfigException("Cannot delete empty tmp file")); } } } else { // If LoadFromFile is 1 - we cannot reach this branch DMATTER_CONFIG_THROW(ConfigException(std::string("File \"") + path_ + std::string("\" exists but shouldn't"))); } #ifdef DMATTER_CONFIG__ENABLE_DEBUG if (ok_) { std::cerr << prefix << "CreateNewFile - Success" << std::endl; } else { std::cerr << prefix << "CreateNewFile - Error(file must not exist)" << std::endl; } #endif } if (!ok_) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << "Must specify LoadFromFile or CreateNewFile flag!" << std::endl; #endif DMATTER_CONFIG_THROW(ConfigException("Must specify LoadFromFile or CreateNewFile flag!")); } #ifdef DMATTER_CONFIG__ENABLE_DEBUG if (ok_) { std::cerr << prefix << "Successfully loaded config(" << path << ")!" << std::endl; } else { std::cerr << prefix << "Error loading config(" << path << ")!" << std::endl; } #endif } Config::Config(const char *path, ConfigFlags f): Config(std::string(path), f) {} Config Config::load_or_init_with(const std::string& path, const nlohmann::json& j, bool save_on_exit) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG const char *prefix = "Config::load_or_init_with(string, json) - "; #endif Config cfg; cfg.path_ = path; cfg.save_on_exit_ = save_on_exit; #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "Trying to load from file(" << path << ")..." << std::endl; #endif if (!cfg.try_load(path)) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "try_load failed! Loading from j parameter and saving..." << std::endl; #endif cfg.json_ = j; cfg.ok_ = true; // try_load turns ok_ to false but we're ok(save() don't work when ok_ is false) cfg.ok_ = cfg.save(); // ok_ will be real after save() #ifdef DMATTER_CONFIG__ENABLE_DEBUG if (cfg.ok_) { std::cerr << prefix << "Saved in file loaded json from j parameted successfully!" << std::endl; } else { std::cerr << prefix << "Error saving loaded json from j parameter!" << std::endl; } #endif } else { #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "try_load successfull!" << std::endl; #endif //DMATTER_CONFIG_THROW(ConfigException(std::string("File \"") + path + std::string("\" cannot be opened"))) } return cfg; } bool Config::try_load(const std::string& path) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG const char *prefix = "dmatter::Config::try_load(string) - "; #endif std::ifstream i(path); if (ok_ = i.is_open()) { i >> json_; } #ifdef DMATTER_CONFIG__ENABLE_DEBUG if (ok_) { std::cerr << prefix << "loaded from file(" << path << ")" << std::endl; } else { std::cerr << prefix << "no such file(" << path << ")" << std::endl; } #endif return ok_; } bool Config::is_ok() { return ok_; } bool Config::save() { #ifdef DMATTER_CONFIG__ENABLE_DEBUG const char *prefix = "Config::save() - "; #endif if (ok_) { std::ofstream o(path_, std::ios::out); if (o.is_open()) { #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "Saved successfully" << std::endl; #endif o << std::setw(4) << json_ << std::endl; return true; } #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "Error opening file \"" << path_ << "\"" << std::endl; #endif } #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "Errors occured :(" << std::endl; #endif return false; } nlohmann::json& Config::operator() () { return json_; } Config::~Config() { #ifdef DMATTER_CONFIG__ENABLE_DEBUG const char *prefix = "Config::~Config() - "; #endif if (save_on_exit_) { save(); } #ifdef DMATTER_CONFIG__ENABLE_DEBUG std::cerr << prefix << "Object deleted" << std::endl; #endif } #ifdef DMATTER_CONFIG__ENABLE_TESTS namespace tests { bool test_all() { const char *prefix = "dmatter::tests::test_all() - "; int tests_passed = 0; const int tests_count = 2; std::cerr << prefix << "TESTS ARE ABOUT TO START" << std::endl;; if (test_create_and_load()) tests_passed++; if (test_load_or_init_with()) tests_passed++; if (tests_passed == tests_count) { std::cerr << prefix << "====[SUCCESS! " << tests_passed << "/" << tests_count << " TESTS ARE PASSED]====" << std::endl; return true; } else { std::cerr << prefix << "====[ERRORS! PASSED " << tests_passed << " of " << tests_count << " tests ]====" << std::endl; return false; } } bool test_create_and_load() { const char *prefix = "dmatter::tests::test_create_and_load() - "; bool ok = false; const char *tmp_filename = ".DMATTER_CONFIG_test_create_and_load.tmp"; std::cerr << prefix << "TEST STARTED" << std::endl << std::endl; try { std::cerr << prefix << "Creating empty new file without saving:" << std::endl; { Config cfg(tmp_filename, ConfigFlags::CreateNewFile); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif } // file successfully created(but not saved) and Config destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Creating empty new file and saving:" << std::endl; { Config cfg(tmp_filename, ConfigFlags::CreateNewFile|ConfigFlags::SaveOnExit); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif } // file successfully created and Config destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Loading created file:" << std::endl; { Config cfg(tmp_filename, ConfigFlags::LoadFromFile); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif } // file successfully opened and Config destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Loading again(and saving with value):" << std::endl; { Config cfg(tmp_filename, ConfigFlags::LoadFromFile|ConfigFlags::SaveOnExit); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif cfg()["test-passed"] = "25%"; } // file successfully opened, rewritten with same content+NEW and destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Loading again(and saving with changed value):" << std::endl; { Config cfg(tmp_filename, ConfigFlags::LoadFromFile|ConfigFlags::SaveOnExit); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif if (cfg()["test-passed"] != "25%") { DMATTER_CONFIG_THROW(ConfigException("TEST FAILED on 25%")); throw std::exception(); } cfg()["test-passed"] = "50%"; } // file successfully opened, rewritten with same content+NEW and destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Loading again(and saving with changed value one more time):" << std::endl; { Config cfg(tmp_filename, ConfigFlags::LoadFromFile|ConfigFlags::SaveOnExit); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif if (cfg()["test-passed"] != "50%") { DMATTER_CONFIG_THROW(ConfigException("TEST FAILED on 50%")); throw std::exception(); } cfg()["test-passed"] = "75%"; } // file successfully opened, rewritten with same content+NEW and destructed std::cerr << "OK!" << std::endl << std::endl; std::cerr << prefix << "Loading again(and saving with changed value even one more time):" << std::endl; { Config cfg(tmp_filename, ConfigFlags::LoadFromFile|ConfigFlags::SaveOnExit); #ifndef DMATTER_CONFIG__ENABLE_THROW if (!cfg.is_ok()) throw std::exception(); #endif if (cfg()["test-passed"] != "75%") { DMATTER_CONFIG_THROW(ConfigException("TEST FAILED on 75%")); throw std::exception(); } cfg()["test-passed"] = "100%"; } // file successfully opened, rewritten with same content+NEW and destructed std::cerr << "OK!" << std::endl << std::endl; ok = true; } catch (ConfigException& e) { std::cerr << prefix << "Expected an exception " << e.what() << std::endl; ok = false; } catch (nlohmann::json::exception& e) { std::cerr << prefix << "Expected an json exception " << e.what() << std::endl; ok = false; } catch (std::exception& e) { std::cerr << prefix << "Expected an exception " << e.what() << std::endl; ok = false; } if (remove(tmp_filename) != 0) { // We'll attemp to delete anyway if (ok) { // If it supposed to be created but errors - show message std::cerr << prefix << "Cannot delete tmp file \"" << tmp_filename << "\"" << std::endl; } ok = false; } std::cerr << prefix << (ok? "TEST PASSED":"TEST FAILED") << std::endl; return ok; } bool test_load_or_init_with() { const char *prefix = "dmatter::tests::test_load_or_init_with - "; bool ok; const char* tmp_filename = ".DMATTER_CONFIG_test_load_or_init_with.tmp"; const char* dummy_key = "DMATTER-dummy-key"; const char* dummy_value = "DMATTER-dummy-value"; std::cerr << prefix << "TEST STARTED" << std::endl; try { std::cerr << prefix << "Init from json(file must not exist):" << std::endl; { auto cfg = Config::load_or_init_with(tmp_filename, [&]() { nlohmann::json j; j[dummy_key] = dummy_value; return j; }()); if (cfg()[dummy_key] != dummy_value) { DMATTER_CONFIG_THROW(ConfigException("Error getting value")); throw std::exception(); } } std::cerr << "OK" << std::endl << std::endl; std::cerr << prefix << "Loading from file(must exist):" << std::endl; { auto cfg = Config::load_or_init_with(tmp_filename, nlohmann::json()); if (cfg()[dummy_key] != dummy_value) { DMATTER_CONFIG_THROW(ConfigException("Error loading from file")); throw std::exception(); } } std::cerr << "OK" << std::endl << std::endl; ok = true; } catch (ConfigException& e) { std::cerr << prefix << "Expected an exception " << e.what() << std::endl; ok = false; } catch (nlohmann::json::exception& e) { std::cerr << prefix << "Expected an json exception " << e.what() << std::endl; ok = false; } catch (std::exception& e) { std::cerr << prefix << "Expected an exception " << e.what() << std::endl; ok = false; } if (remove(tmp_filename) != 0) { // We'll attemp to delete anyway if (ok) { // If it supposed to be created but errors - show message std::cerr << prefix << "Cannot delete tmp file \"" << tmp_filename << "\"" << std::endl; } ok = false; } std::cerr << prefix << (ok? "TEST PASSED":"TEST FAILED") << std::endl; return ok; } } // namespace tests #endif // DMATTER_CONFIG__ENABLE_TESTS } // namespace dmatter
[ "noreply@github.com" ]
noreply@github.com
9006e63ae74560cd10a5620bc4363f7d39109140
2cfd9abad460b562b3f901887af39c90c221c9bf
/document.hpp
70067efabbce56c1bcc8f1017e9c959ab6b0d2f3
[]
no_license
ruslanas/b2
e768aa827eb1d250afd59e991a1639306e743ca3
9f564fca7d6a34fc02b2b4ad8e8261de29465ef3
refs/heads/master
2021-01-10T04:34:06.338754
2016-01-25T23:23:52
2016-01-25T23:23:52
50,344,622
1
0
null
null
null
null
UTF-8
C++
false
false
729
hpp
#ifndef _R_DOCUMENT_H #define _R_DOCUMENT_H #include <iostream> #include <vector> #include <string> #include <map> #include <fstream> #include "node.hpp" using namespace std; namespace R { class File { protected: string path; public: virtual void load(string path) = 0; virtual void save() = 0; }; class Document : public File { private: friend ostream & operator<< (ostream & os, Document & doc); string title; vector<Node *> nodes; public: Node root; Document(string title = "Untitled"); Document(Node & root); ~Document(); string getTitle() const; Node * createNode(string name); void load(string path); void save(); string toXML(); }; } #endif
[ "ruslanas.com@gmail.com" ]
ruslanas.com@gmail.com
62f027cad0d8402610c74d1a1eb77339572158cd
7d54050413250d12d6c3137ebba6796c11c64502
/BerryArm/src/utilities/XM_bulk_chain_change_baudrate.cpp
19fa3fc61193b71ba94db79ca09a338b6f350a13
[]
no_license
AssociationRobotTelecomStrasbourg/Dynamixel
a16ad1ddd2bf6b5279f36d1900a4ad187e96e514
f4a2fe077b6779c64b95b318710ca7c4d03f6480
refs/heads/master
2020-04-06T19:33:56.989275
2019-11-26T14:25:28
2019-11-26T14:25:28
157,741,329
0
0
null
null
null
null
UTF-8
C++
false
false
397
cpp
#include "XM_bulk_chain.h" #include "XM430-W210_Control_Table.h" int main(int argc,char** argv) { createControlTable(); XM_bulk_chain* Chain; Chain = new XM_bulk_chain(5,1000000); uint8_t baudrate = 1; for(int id=1;id<6;id++) { Chain->setParam(id,"Baud Rate",baudrate); } Chain->write(); delete Chain; Chain = new XM_bulk_chain(5); return 0; }
[ "36369273+rkuroi@users.noreply.github.com" ]
36369273+rkuroi@users.noreply.github.com
5d162249d620f14c14e318738f6658eed0cff54d
c8cd796ae9ae36a45974bd32be65f471dd07a8d7
/Past projects/C++ - 11th grade/program/MacroOperation.hh
2d5b3fe4e2df09f47ba044f8dd1e98f2f8131cbe
[]
no_license
TheScouser/projects
b4647467faf47ae34e21a71d56bd110df49a14d2
19bf5317d13e7878e5a55714d5c1c1d13d57e161
refs/heads/master
2021-01-23T06:35:13.659053
2017-02-20T21:00:46
2017-02-20T21:00:46
35,447,608
0
0
null
null
null
null
UTF-8
C++
false
false
298
hh
#ifndef MACRO_OPERATION_HH__ #define MACRO_OPERATION_HH__ #include <list> #include "Operation.hh" class MacroOperation: public Operation { std::list<Operation*>ops_; public: MacroOperation(const std::string& name); void add_op(Operation* op); void calc(Context& context) const; }; #endif
[ "edward.kalfov@gmail.com" ]
edward.kalfov@gmail.com
a4af6755275534faba32a1082f3e0067b8620b08
3bd3d1ff4b62046273beea9516df64deea281646
/src/YouMeIMEngine/Speech/OSX/OSXVoiceManager.h
42c8278112089419cc5b90a90d8771d9963ddb16
[]
no_license
cansou/IMSDK
37604d7a6a7a7ad738442989f5da5639f90c2d22
6dde2b96ef8a641ca9b7d354038e0e39a341466d
refs/heads/master
2022-09-04T01:36:52.861167
2020-05-24T09:47:27
2020-05-24T09:47:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,345
h
#ifndef OSX_VOICE_MANAGER_H #define OSX_VOICE_MANAGER_H #include <string> #include "YouMeIMEngine/Speech/VoiceInterface.h" class OSXVoiceManager : public IYoueVoiceManager { public: OSXVoiceManager(); virtual bool Init(const std::string& appkey, const std::string& secret, AudioRecognizeType audioRecognizeType) override; virtual void UnInit() override; virtual void SetAudioListener(IAudioListener* listener) override; virtual void SetAudioRecordCacheDir(const XString& path) override; virtual XString GetAudioRecordCacheDir() override; virtual void SetAudioRecordParam(int sampleRate, int channel, int sampleBitSize) override; virtual int StartSpeech(XUINT64 serial) override; virtual int StartOnlySpeech(XUINT64 serial) override; virtual int StopSpeech() override; virtual int CancleSpeech() override; virtual void SetRecognizeLanguage(RecognizeLanguage language) override; virtual void SetKeepRecordModel(bool keep) override; virtual void UpdateToken(const std::string& token) override; virtual int StartPlayAudio(const XString& path) override; virtual int StopPlayAudio() override; virtual bool IsPlaying() override; virtual void SetPlayVolume(float volume) override; virtual int GetMicrophoneStatus() override; private: }; #endif
[ "shuhuan_bruce@icloud.com" ]
shuhuan_bruce@icloud.com
4042c9b308356b87df030b87217e980106082dc9
02ce34f6064d63266069a0d9f4e16b4086285a17
/src/ui/Windows/YubiMixin.h
e6587980127fa904d4f7903e6150c68777ba1cac
[ "Artistic-2.0", "MIT" ]
permissive
cantbewong/passwordsafe
f2567cfbebcfd11fdee6a46259d09a009e7e7e44
6645ffe5a9d4c28f33f73dc4af3425b32fc1d729
refs/heads/master
2021-01-19T07:01:41.195324
2016-07-27T16:23:38
2016-07-27T16:23:38
64,323,774
0
1
null
null
null
null
UTF-8
C++
false
false
3,062
h
/* * Copyright (c) 2003-2016 Rony Shapiro <ronys@pwsafe.org>. * All rights reserved. Use of the code is allowed under the * Artistic License 2.0 terms, as specified in the LICENSE file * distributed with this code, or available from * http://www.opensource.org/licenses/artistic-license-2.0.php */ /** * CYubiMixin is a means of sharing the common YubiKey controls * and related code across dialogs that provide YubiKey authentication * * Compiles to empty stub under NO_YUBI */ #pragma once #include "SecString.h" #include "os/windows/yubi/YkLib.h" #ifndef NO_YUBI #include <afxmt.h> // for CMutex class CYubiMixin { public: CYubiMixin(); // Following help us assure that if a YubiKey's // inserted in *any* dbox that uses it, others will reflect this. static bool YubiExists() {return s_yubiDetected;} static void SetYubiExists() {s_yubiDetected = true;} protected: void YubiPoll(); // Call this in Timer callback virtual void ProcessPhrase() {}; // Check the passphrase, call OnOK, OnCancel or just return virtual void YubiFailed() {}; // Yubico-related: bool IsYubiInserted() const; void yubiCheckCompleted(); // called when request pending and timer fired // Callbacks: virtual void yubiShowChallengeSent() = 0; // request's in the air, setup GUI to wait for reply virtual void yubiProcessCompleted(YKLIB_RC yrc, unsigned short ts, const BYTE *respBuf) = 0; // called by yubiCheckCompleted() virtual void yubiInserted(void) = 0; // called when Yubikey's inserted virtual void yubiRemoved(void) = 0; // called when Yubikey's removed void yubiRequestHMACSha1(const CSecString &challenge); // request HMAC of passkey StringX Bin2Hex(const unsigned char *buf, int len); static bool s_yubiDetected; // set if yubikey was inserted in the app's lifetime. mutable CYkLib m_yk; bool m_yubiPollDisable; bool m_pending; // request pending? bool m_present; // key present? mutable CMutex m_mutex; // protect against race conditions when calling Yubi API }; #else /* NO_YUBI - all no-op */ class CYubiMixin { public: CYubiMixin() {} static bool YubiExists() {return false;} static void SetYubiExists() {} protected: void YubiPoll() {} virtual void ProcessPhrase() {}; // Check the passphrase, call OnOK, OnCancel or just return virtual void YubiFailed() {}; // Yubico-related: bool IsYubiInserted() const {return false;} void yubiCheckCompleted() {} // Callbacks: virtual void yubiShowChallengeSent() = 0; // request's in the air, setup GUI to wait for reply virtual void yubiProcessCompleted(YKLIB_RC yrc, unsigned short ts, const BYTE *respBuf) = 0; // called by yubiCheckCompleted() virtual void yubiInserted(void) = 0; // called when Yubikey's inserted virtual void yubiRemoved(void) = 0; // called when Yubikey's removed void yubiRequestHMACSha1(const CSecString &) {} StringX Bin2Hex(const unsigned char *, int ) {return StringX(L"");} bool m_yubiPollDisable; bool m_pending; // request pending? bool m_present; // key present? }; #endif /* NO_YUBI */
[ "steven.wong@emc.com" ]
steven.wong@emc.com
3dd68cefdaaa2d27950be3ec12b0b8af457ec436
aa0e73afc7f7e06c626ab898cdf8dcabd5c2cfa8
/src/codegen/output.hpp
a54e48f912d175b86abceb958cf2595c478afd04
[ "BSL-1.0", "MIT" ]
permissive
gamagan/vpp
8c466ce65c39317a3765ddd652d5cab26a9ed9fc
2bd7c8ab1900cf4630176321b885b770d0a9117a
refs/heads/master
2021-07-06T04:39:13.172046
2017-07-27T11:13:10
2017-07-27T11:13:10
106,061,676
1
0
null
2017-10-07T00:45:54
2017-10-07T00:45:54
null
UTF-8
C++
false
false
5,483
hpp
// Copyright (c) 2017 nyorain // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt #pragma once #include <string> #include <fstream> #include <vector> class Registry; class Param; class Type; class QualifiedType; class Enum; class Constant; class Command; class Requirements; class Struct; /// OutputGenerator base class, used for outputting a Registry in a specific language /// or format. Implements various utility functions. class OutputGenerator { public: // removes a vk or VK prefix (case does not matter) // if the string startes with VK_ also removes the first underscore. std::string removeVkPrefix(const std::string& string, bool* found) const; bool removeVkPrefix(std::string& string) const; // removes the extension or tag suffix from a string. // Uses the stored registry to query valid extensions (vendor) suffixes. // Will also remove tag suffixes (such as KHR or EXT) // The second (in-place) overload returns the found extension/tag. std::string removeExtSuffix(const std::string& string, std::string* extension) const; std::string removeExtSuffix(std::string& string) const; // brings the given string into camelCase. // If firstupper is true, also capitalizes the first char. // Example: camelCase(TEST_CASE_ABC_de, true) -> TestCaseAbcDe std::string camelCase(const std::string& string, bool firstupper = false) const; void camelCaseip(std::string& string, bool firstupper = false) const; // brings the given string from camel case from into macro caes, i.e. all chars // to uppercase and seperates words (previously seperated by a uppercase char) // with an underscore. // Example: macroCase(camelCaseWordABC) -> CAMEL_CASE_A_B_C std::string macroCase(const std::string& string) const; void macroCaseip(std::string& string) const; // strips the given string to the important information by removing the vk prefix, // andy extensions prefix and bringing it to camel case. std::string strip(const std::string& string) const; void stripip(std::string& string) const; // the associated registry Registry& registry() const { return *registry_; } protected: OutputGenerator(Registry& reg) : registry_(&reg) {} Registry* registry_; }; struct CCOutputGeneratorSettings { std::string outputFolder = "."; }; struct ParsedParam { const Param* param; // if parsed param is array it references the count param ParsedParam* countPar = nullptr; const Param* countMember = nullptr; // if parsed param is count std::vector<ParsedParam*> dataPars; bool memberAsCount = false; // if it is count, whether the count is a struct member // whether the param is an out param bool out = false; // whether the param is optional bool optional = false; bool optionalWithRet = false; // whehter it is optional if return param is normal param }; struct ParsedCommand { const Command* command = nullptr; std::vector<ParsedParam> parsedParams; ParsedParam* returnParam = nullptr; // the data part of the return param }; class CCOutputGenerator : public OutputGenerator { public: CCOutputGenerator(Registry& reg, const CCOutputGeneratorSettings& settings = {}); // generates the header files from the registry and settings passed in constructor void generate(); // outputs everything of the given Requirements to the matching header files. // the guard parameter can be passed for an additional macro guard around the reqs. // will skip requirements that are already in the passed fulfilled ones. void printReqs(Requirements&, const Requirements& fulfilled, const std::string& guard = ""); // outputs the given entities to the matching headers files void printStruct(const Struct& type); void printCmd(const Command& command); void printVecCmd(const Command& command, const Param& count, const Param& data); void printVecCmd(const ParsedCommand& command, const std::string& name); // parses the command, i.e. tries to vectorize and analyze it. ParsedCommand parseCommand(const Command& cmd) const; // outputs the param declaration for the given parsed parameter. // if rangify is true will try to convert it into a span // sepr is the seperator to put in front of the parameter std::string paramDecl(const ParsedParam& param, bool rangeify, const char* sepr, const ParsedParam* retParam) const; std::string paramCall(const ParsedParam& param, bool rangeify, const char* sepr, const ParsedParam* retParam) const; /// returns the names of the given entities for c++ std::string enumName(const Enum& e, const std::string& name, bool* bit = nullptr) const; std::string constantName(const Constant& c) const; std::string typeName(const Type& type) const; std::string typeName(const QualifiedType& type, bool change = true) const; std::string paramName(const Param&, const std::string& namePrefix = "", bool plainArray = false) const; // outputs to all headers // the second function does not output to main, i.e. the central header void outputAll(const std::string& output); void outputAllHeader(const std::string& output); // assures the the given guard is set in guardVar, otherwise prints it to of and sets it void assureGuard(std::ofstream& of, bool& guardVar, const std::string& guard); void endGuard(std::ofstream& of, bool guardVar, const std::string& guard); protected: std::ofstream main_; std::ofstream functions_; std::ofstream enums_; std::ofstream structs_; std::ofstream fwd_; };
[ "nyorain@gmail.com" ]
nyorain@gmail.com
9fe0afa662481979fb7474f72ef7622d971c4ba0
5b00f4cf3f872afe4962e5b43458d06b49c42bb3
/BOJProblem/p4504.cpp
84a80bb6f93a06e6c22cdd85c62c5c1f6894b6c4
[]
no_license
AllisonLee0507/BOJProblem
4e8884a104c6e4a770a1d1a979cc32b15fa39246
cacb3fed3b6a7ad9be923d25fc876b0c65114202
refs/heads/master
2023-07-10T23:30:25.470586
2021-08-22T04:49:54
2021-08-22T04:49:54
398,716,320
0
0
null
null
null
null
UTF-8
C++
false
false
716
cpp
#define _CRT_SECURE_NO_WARNINGS #if 0 #include <stdio.h> int main(){ int N; scanf("%d", &N); while(1){ int var; scanf("%d", &var); if (var == 0){ break; } printf("%d is %sa multiple of %d.\n", var, var%N ? "NOT " : "", N ); } } #endif #if 0 #include <iostream> using namespace std; int main(){ int N; cin >> N; while(1){ int var; cin >> var; if (var == 0){ break; } if (var%N != 0){ cout << var << " is NOT a multiple of " << N << ".\n"; } else if (var%N == 0){ cout << var << " is a multiple of " << N << ".\n"; } } } #endif
[ "65398946+AllisonLee0507@users.noreply.github.com" ]
65398946+AllisonLee0507@users.noreply.github.com
bec4a44c0c9d1b850e0add6674ddff81f7d556b6
70418d8faa76b41715c707c54a8b0cddfb393fb3
/12832.cpp
df757655dafa2280490a5e97d8767bb287ae1d08
[]
no_license
evandrix/UVa
ca79c25c8bf28e9e05cae8414f52236dc5ac1c68
17a902ece2457c8cb0ee70c320bf0583c0f9a4ce
refs/heads/master
2021-06-05T01:44:17.908960
2017-10-22T18:59:42
2017-10-22T18:59:42
107,893,680
3
1
null
null
null
null
UTF-8
C++
false
false
721
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { long long t; while (x % y) t = x, x = y, y = t % y; return y; } long long lcm(long long x, long long y) { return x / gcd(x, y) * y; } void simplify(long long &x, long long &y) { long long g = gcd(x, y); x /= g, y /= g; } int main() { int testcase, cases = 0, n; scanf("%d", &testcase); while (testcase--) { scanf("%d", &n); long long a = 0, b = 1, x, y; for (int i = 0; i < n; i++) { scanf("%lld %lld", &y, &x); simplify(x, y); long long ta, tb = lcm(b, y); ta = a * (tb / b) + x * (tb / y); a = ta, b = tb; simplify(a, b); } printf("Case %d: %lld/%lld\n", ++cases, a, b); } return 0; }
[ "yleewei@dso.org.sg" ]
yleewei@dso.org.sg
9bb3c16bd1a1cf548414896b451c7906e0aa01ce
b77bb0f73d06e736553bc98fd875eaf97d5c7581
/homework17..cpp
db8bb2705b3a561f9ba54f96b22b2b7187e5b198
[]
no_license
bayraa77/while-loop
ce366f6f7c71804080dfdede0dd01976769c96b1
1a7ff268e69736846fce50599dad35c7131a80fc
refs/heads/main
2023-05-08T01:50:28.736176
2021-06-01T05:51:18
2021-06-01T05:51:18
372,715,662
0
0
null
null
null
null
UTF-8
C++
false
false
302
cpp
#include<iostream> using namespace std; int main(){ int num, a,b,temp=0; cout<<" enetr numbers = "; cin>>num; b =num; while(num>0){ a=num%10; num=num/10; temp=temp*10+a; }if(temp==b){ cout<<temp<< " is palindrome "; }else{ cout<<temp<<" is not palindrome "; } }
[ "noreply@github.com" ]
noreply@github.com
4f82a31c6459b5cbc2eb896a38a33abd9b02af59
d865c4d23ce87a06aec2c1a7298aef9273b1245c
/app.cpp
e686339ddafb4e5f31e3278b8567eb9a74f7579e
[]
no_license
crazyNub/lab3
141f3d414a41a4cb65ef83ea088c980c633e1885
90825aa79220e5e46b6f5f2ccde07d91bc480f6f
refs/heads/master
2021-03-06T21:35:49.810725
2020-03-10T06:36:42
2020-03-10T06:36:42
246,225,299
0
0
null
null
null
null
UTF-8
C++
false
false
1,700
cpp
#include "cl_application.h" cl_application::cl_application() { set_object_name("root"); set_state(1); } void cl_application::bild_tree_objects() { p_ob_1 = new cl_1(); p_ob_1->set_object_name("ob_1"); p_ob_1->set_parent(this); p_ob_11=p_ob_1; p_ob_2 = new cl_2(); p_ob_2->set_object_name("ob_2"); p_ob_2->set_parent(p_ob_1); p_ob_3 = new cl_3(); p_ob_3->set_object_name("ob_3"); p_ob_3->set_parent(p_ob_2); p_ob_33=p_ob_3; p_ob_4 = new cl_4(); p_ob_4->set_object_name("ob_4"); p_ob_4->set_parent(p_ob_2); p_ob_4 = new cl_4(); p_ob_4->set_object_name("ob_5"); p_ob_4->set_parent(p_ob_1); p_ob_55=p_ob_4; p_ob_1 = new cl_1(); p_ob_1->set_object_name("ob_6"); p_ob_1->set_parent(this); p_ob_2 = new cl_2(); p_ob_2->set_object_name("ob_7"); p_ob_2->set_parent(this); p_ob_3 = new cl_3(); p_ob_3->set_object_name("ob_8"); p_ob_3->set_parent(p_ob_2); last_obj_name = p_ob_3->get_object_name(); } int cl_application::exec_app() { show_tree((cl_base*)this, 0, last_obj_name); p_ob_11->set_connect(SIGNAL_D(p_ob_11->signal_1), p_ob_55, HENDLER_D (p_ob_55->hendler_1)); p_ob_11->set_connect(SIGNAL_D(p_ob_11->signal_2), p_ob_55, HENDLER_D (p_ob_55->hendler_2)); p_ob_11->set_connect(SIGNAL_D(p_ob_11->signal_2), p_ob_33, HENDLER_D (p_ob_33->hendler_1)); int interaction; string text; cin>>interaction; while (interaction) { cin>>text; switch (interaction) { case 1: p_ob_11->emit_signal(SIGNAL_D(p_ob_11->signal_1), text); break; case 2: p_ob_11->emit_signal(SIGNAL_D(p_ob_11->signal_2), text); break; case 3: p_ob_11->emit_signal(SIGNAL_D(p_ob_11->signal_2), text); break; } cin>>interaction; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
f09e135a539db7c914778ba9c04fdbf57e2b7fa5
682318d057887a3e689ab80ca6daa22b097c4a82
/cpp/krasi/hw4/hw4.cpp
e17aad12d93dec30ad20984e25591657e55533b9
[ "MIT" ]
permissive
logicalclick/web
7393b84d697d2c0cfdcc3484d4a1f9fa6dcdd30d
29eec38310c2708431bf098667e1c5d1f8f09577
refs/heads/master
2021-01-20T21:52:26.684806
2015-12-23T05:22:03
2015-12-23T05:22:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,584
cpp
#include <iostream> #include <string> #include <cassert> #include <stdio.h> #include <stdlib.h> #include <assert.h> using namespace std; /* You will have to implement a function that will use C++ string object in order to reverse the letter in each word of a sentence. INFO: http://www.math.bas.bg/~nkirov/2012/WCP/STL/STL.pdf (string) http://anaturb.net/C/string_exapm.htm http://www.cprogramming.com/tutorial/string.html https://www.youtube.com/watch?v=2_znS5i92pM Example: I am born in a village => I ma nrob ni a egalliv */ //int main () string rev_sent(const string s) { /* Write your code here */ string word; string revword; string rests1 = s; string rests2 = s; string res = ""; string sign = ""; unsigned int i = 0; unsigned int j = 0; unsigned int k = 0; unsigned int wordnum = 1; for(i = 0; i < s.size(); i++) //count number of words { if (s[i] == ' ') wordnum = wordnum + 1; } for (j = 0;j < wordnum-1;j++) { word = rests1.erase ( rests1.find (' ',0), rests1.size () - 1 ); //separate each word w/o last from the beginning rests1 = rests2.erase (0, word.size ()+1); if (word[word.size ()-1] ==',') //separate sign after each word w/o last { sign = ',' ; word = word.erase(word.size ()-1,1); } revword = word; for ( k = 0; k < word.size () ; k++ )//reverse each word w/o last { revword[word.size ()-k-1]=word[k]; } revword[word.size ()] = '\0'; res = res.append (revword + sign + ' ');// append each reversed word w/o last to result sign = ""; } if (rests1[rests1.size ()-1] =='.') //separate sign after last word { sign = '.' ; rests1 = rests1.erase(rests1.size ()-1,1); } revword = rests1; for ( k = 0; k < rests1.size () ; k++ )//reverse last word { revword[rests1.size ()-k-1]=rests1[k]; } revword[rests1.size ()] = '\0'; res = res.append (revword + sign);// append each reversed word to result return res; } int main(int argc, char** argv) { unsigned int i; const string sentence_in[] = { "We are born in this village", "", "GitHub", "I", "wow wow wow", "Miami is a big city.", "My favourite pie remains the standard traditional meat pie.", "If you want a sit down meal in one of these cafes or bakeries, then that is no problem.", "You can order your pie with salad and chips and it will come on a plate.", "A meat pie tastes just as good when eaten with a knife and fork.", "A visit to the local cafe or bakery is a must in any small town in country Australia, \ or indeed in any suburb of a major city.", "When you visit, be sure to order a meat pie, a real taste of Australia." }; const string sentence_out[] = { "eW era nrob ni siht egalliv", "", "buHtiG", "I", "wow wow wow", "imaiM si a gib ytic.", "yM etiruovaf eip sniamer eht dradnats lanoitidart taem eip.", "fI uoy tnaw a tis nwod laem ni eno fo eseht sefac ro seirekab, neht taht si on melborp.", "uoY nac redro ruoy eip htiw dalas dna spihc dna ti lliw emoc no a etalp.", "A taem eip setsat tsuj sa doog nehw netae htiw a efink dna krof.", "A tisiv ot eht lacol efac ro yrekab si a tsum ni yna llams nwot ni yrtnuoc ailartsuA, \ ro deedni ni yna brubus fo a rojam ytic.", "nehW uoy tisiv, eb erus ot redro a taem eip, a laer etsat fo ailartsuA." }; for (i = 0; i < sizeof(sentence_in)/sizeof(sentence_in[0]); i++) { cout << sentence_out[i] << endl << rev_sent(sentence_in[i]) << endl; cout << "Test " << i+1 << ": "; assert( rev_sent(sentence_in[i]) == sentence_out[i] ); cout << "OK" << endl; } return 0; }
[ "krasizah@abv.bg" ]
krasizah@abv.bg
3ac859ab50cfaf16a976e15ce069b26771b14f50
c5d4ab08ed3e462860694e9d501b51b9b98a25a1
/jakas_gra/food.h
a07095992cca915eb5598f88fdf09aa7542dbbb9
[]
no_license
danielroslon/jakas_gra
59e87dbf980e7b285d2c24419a33c91a11d3a889
866eb2e4e2ce82a0e9f2d1461d43e4f0e3eb95a0
refs/heads/master
2021-08-09T02:56:51.805146
2017-11-12T01:10:10
2017-11-12T01:10:10
107,849,081
0
0
null
null
null
null
UTF-8
C++
false
false
324
h
#pragma once #include <SFML/Graphics.hpp> #include <iostream> #include <ctime> #include <string> using namespace sf; class food { private: RectangleShape shape; Vector2f position; public: food(); food(Vector2u); ~food(); food& operator=(const food&); Vector2f getPosition(); void rysowanie(RenderWindow*); };
[ "32789908+danielroslon@users.noreply.github.com" ]
32789908+danielroslon@users.noreply.github.com
e87769c533798100598bda270c8922da7f5bf3b6
63b15515c81558e856ed47e2b30325d33274962e
/StrMatrix/TPZSpStructMatrix.h
ea7232cdd991e2407c2237ef69644d4731542283
[]
no_license
diogocecilio/neopz-master
eb14d4b6087e9655763440934d67b419f781d1a0
7fb9346f00afa883ccf4d07e3ac0af466dfadce1
refs/heads/master
2022-04-04T21:44:17.897614
2019-10-25T20:34:47
2019-10-25T20:34:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
837
h
/** * @file * @brief Contains the TPZSpStructMatrix class which implements sparse structural matrices. */ #ifndef TPZSPSTRUCTMATRIX_H #define TPZSPSTRUCTMATRIX_H #include "pzstrmatrix.h" #include "pzysmp.h" #include "pzcmesh.h" #include "pzsubcmesh.h" #include "pzelmat.h" #include "pzmatrix.h" #include "pzfmatrix.h" /** * @brief Implements Sparse Structural Matrices. \ref structural "Structural Matrix" * @ingroup structural */ class TPZSpStructMatrix : public TPZStructMatrix { public: TPZSpStructMatrix(TPZCompMesh *); virtual TPZMatrix<STATE> * Create(); virtual TPZMatrix<STATE> * CreateAssemble(TPZFMatrix<STATE> &rhs, TPZAutoPointer<TPZGuiInterface> guiInterface); virtual TPZStructMatrix * Clone(); /** Used only for testing */ static int main(); }; #endif //TPZSPSTRUCTMATRIX_H
[ "cecilio.diogo@gmail.com" ]
cecilio.diogo@gmail.com
eddf6b9b2574b49de9c6b222cd94ca3df0ea7583
439345dd198e559f1c71f384020a99069f9151de
/practice/KthSmallestinBST.cpp
092ed695cb95fbcf76f0150c096e563a9d30737d
[]
no_license
kanusahai/EPI
2bfd303dcb58f53d790ad43e194f5a3f32917f77
8dbefdf09489ce16a2c2b133a7dc0b2949259fc8
refs/heads/master
2021-01-17T11:28:11.655233
2016-08-07T21:12:01
2016-08-07T21:12:01
63,545,235
0
0
null
null
null
null
UTF-8
C++
false
false
827
cpp
#include <iostream> using namespace std; struct node { int value; node* left; node* right; }; void inorder(node *root, int *k, node **result, int K) { if(root==NULL) return; inorder(root->left, k, result, K); *k+=1; if(*k==K) { *result=root; return; } inorder(root->right, k, result, K); } node* findKthSmallest(node* root, int K) { node **result = new node*(); int *k=new int(0); inorder(root,k,result,K); return *result; } int main() { node *root = new node(); root->left=new node(); root->left->value=1; root->left->left=NULL; root->left->right=NULL; root->value=2; root->right=new node(); root->right->value=3; root->right->left=NULL; root->right->right=NULL; node *kthNode=findKthSmallest(root, 2); if(kthNode!=NULL) { cout<<kthNode->value<<"\n"; } return 0; }
[ "kanusahai@yahoo-inc.com" ]
kanusahai@yahoo-inc.com
a442f8a60e2e64aec195e8a92d94529919d1b117
a30646df8797db80cc41b5702c963b069f4e322a
/plugins/GSdx/GSDump.cpp
29d93009a54c1f05a059c43912fb0a5daba2b6c2
[]
no_license
fraserofsmeg/PCSX2-origonal
39793fd9b5d5a919352ad6aa5c439c01d2ad5450
cee19743aa605808c69fa2ca9464064a3c3df844
refs/heads/master
2020-03-23T17:01:24.795940
2018-07-21T18:58:11
2018-07-21T18:58:11
141,838,785
0
0
null
null
null
null
UTF-8
C++
false
false
3,119
cpp
/* * Copyright (C) 2007-2009 Gabest * http://www.gabest.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "GSDump.h" GSDump::GSDump() : m_gs(NULL) , m_obj(NULL) , m_frames(0) , m_objects(0) , m_vertices(0) { } GSDump::~GSDump() { Close(); } void GSDump::Open(const string& fn, uint32 crc, const GSFreezeData& fd, const GSPrivRegSet* regs) { m_gs = fopen((fn + ".gs").c_str(), "wb"); m_obj = fopen((fn + ".obj").c_str(), "wt"); m_frames = 0; m_objects = 0; m_vertices = 0; if(m_gs) { fwrite(&crc, 4, 1, m_gs); fwrite(&fd.size, 4, 1, m_gs); fwrite(fd.data, fd.size, 1, m_gs); fwrite(regs, sizeof(*regs), 1, m_gs); } } void GSDump::Close() { if(m_gs) {fclose(m_gs); m_gs = NULL;} if(m_obj) {fclose(m_obj); m_obj = NULL;} } void GSDump::Transfer(int index, const uint8* mem, size_t size) { if(m_gs && size > 0) { fputc(0, m_gs); fputc(index, m_gs); fwrite(&size, 4, 1, m_gs); fwrite(mem, size, 1, m_gs); } } void GSDump::ReadFIFO(uint32 size) { if(m_gs && size > 0) { fputc(2, m_gs); fwrite(&size, 4, 1, m_gs); } } void GSDump::VSync(int field, bool last, const GSPrivRegSet* regs) { if(m_gs) { fputc(3, m_gs); fwrite(regs, sizeof(*regs), 1, m_gs); fputc(1, m_gs); fputc(field, m_gs); if((++m_frames & 1) == 0 && last) { Close(); } } } void GSDump::Object(GSVertexSW* vertices, int count, GS_PRIM_CLASS primclass) { if(m_obj) { switch(primclass) { case GS_POINT_CLASS: // TODO break; case GS_LINE_CLASS: // TODO break; case GS_TRIANGLE_CLASS: for(int i = 0; i < count; i++) { float x = vertices[i].p.x; float y = vertices[i].p.y; float z = vertices[i].p.z; fprintf(m_obj, "v %f %f %f\n", x, y, z); } for(int i = 0; i < count; i++) { fprintf(m_obj, "vt %f %f %f\n", vertices[i].t.x, vertices[i].t.y, vertices[i].t.z); } for(int i = 0; i < count; i++) { fprintf(m_obj, "vn %f %f %f\n", 0.0f, 0.0f, 0.0f); } fprintf(m_obj, "g f%d_o%d_p%d_v%d\n", m_frames, m_objects, primclass, count); for(int i = 0; i < count; i += 3) { int a = m_vertices + i + 1; int b = m_vertices + i + 2; int c = m_vertices + i + 3; fprintf(m_obj, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", a, a, a, b, b, b, c, c, c); } m_vertices += count; m_objects++; break; case GS_SPRITE_CLASS: // TODO break; } } }
[ "fraserjamesrobinson@gmail.com" ]
fraserjamesrobinson@gmail.com
9108520c289382378c869c9f7b12a66cad288455
f9f728a3a92b36b99e403a3136cbb513bdea3063
/medicalrecordwindow.cpp
817a43072e9d888a4e1e7f9b8514824dbd2c0045
[]
no_license
jbakhtin/Registration-polyclinic-v2
e8f05ddfbb16241436d653c016e87687e38c2309
7e629de71bb5f27873d88922124983389f964168
refs/heads/master
2021-09-19T11:42:18.052981
2018-07-27T14:48:28
2018-07-27T14:48:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,965
cpp
#include "medicalrecordwindow.h" #include "ui_medicalrecordwindow.h" MedicalRecordWindow::MedicalRecordWindow(QWidget *parent) : QDialog(parent), ui(new Ui::MedicalRecordWindow) { ui->setupUi(this); } MedicalRecordWindow::~MedicalRecordWindow() { delete ui; } void MedicalRecordWindow::us(UserLists *d){ userlists = d; } void MedicalRecordWindow::setPreferences(Doctor *doctor, MedicalRecord *medRec, Patient *patient){ mDoctor = doctor; mPatient = patient; mMedicalRecord = medRec; ui->stackedWidget->setCurrentIndex(0); inicialDoctor = mDoctor->getSurname() + " " + mDoctor->getName()[0] + " " + mDoctor->getPatronymic()[0]; ui->label_RecordDoctor->setText(inicialDoctor); ui->pushButton_record->setEnabled(false); ui->pushButton_back->setVisible(false); this->setWindowTitle("Запись к врачу "); QIcon winIcon("images//edit.svg"); this->setWindowIcon(winIcon); } void MedicalRecordWindow::on_pushButton_record_clicked() { mMedicalRecord->setLogin(mPatient->getLogin()); mMedicalRecord->setDate(ui->calendarWidget->selectedDate().toString()); QModelIndex idIndex = ui->listWidget->currentIndex(); mMedicalRecord->setTime(idIndex.data().toString()); mMedicalRecord->setDoctor(inicialDoctor); QDialog::accept(); } void MedicalRecordWindow::on_pushButton_next_clicked() { ui->stackedWidget->setCurrentIndex(1); ui->pushButton_record->setEnabled(true); ui->pushButton_next->setVisible(false); ui->pushButton_back->setVisible(true); QString date = ui->calendarWidget->selectedDate().toString(); ui->listWidget->addItems(userlists->listDateTimeRecord(date)); } void MedicalRecordWindow::on_pushButton_back_clicked() { ui->stackedWidget->setCurrentIndex(0); ui->pushButton_record->setEnabled(false); ui->pushButton_next->setVisible(true); ui->pushButton_back->setVisible(false); ui->listWidget->clear(); }
[ "jurij.bakhtin@gmail.com" ]
jurij.bakhtin@gmail.com
e1476ad014ac9f9001ba2e24114921c8ae6e3fb8
b2ca479b5a9cb1917868770e622b47e14d5b4db9
/TrieUsage.cpp
a3155277233fa41b64d50ff557fd1dadb821eefe
[]
no_license
orel1108/algorithms_and_data_structures
18aa16411a779297836ef04f1bfa0144b88205da
c640a3773f471922826d4ccb19f060f20c914b05
refs/heads/master
2021-01-19T04:22:42.354203
2016-06-10T12:47:44
2016-06-10T12:47:44
53,673,469
0
0
null
null
null
null
UTF-8
C++
false
false
1,759
cpp
#include <string> #include "TrieUsage.hpp" namespace { /** * @brief Converts character to index. * @param[in] i_chr Input character. * @return Index of character. */ int idx(char i_chr) { return (i_chr == '.') ? 10 : (i_chr - '0'); } } /** * @brief Add IP address and corresponding URL. * @param[in] i_ip IP address. * @param[in] i_url URL. */ void ReverseDNSCache::insert(const std::string & i_ip, const std::string & i_url) { // copy root Node * node = m_root; for (std::size_t level = 0; level < i_ip.size(); ++level) { // get index of character int index = idx(i_ip[level]); if (node->child[index] == nullptr) { // create new node node->child[index] = new Node; } // move to next node node = node->child[index]; } // set URL node->url = i_url; // mark node as leaf node node->is_leaf = true; } /** * @brief Reverse DNS search. * @param[in] i_ip IP address. * @return URL which corresponds to given IP. */ std::string ReverseDNSCache::search(const std::string & i_ip) const { // copy root Node * node = m_root; for (std::size_t level = 0; level < i_ip.size(); ++level) { // get index of character int index = idx(i_ip[level]); // IP not found if (node->child[index] == nullptr) { return std::string("IP not found"); } // move to next node node = node->child[index]; } // found IP if (node != nullptr && node->is_leaf) { return node->url; } return std::string("IP not found"); }
[ "r.orlovskyi@gmail.com" ]
r.orlovskyi@gmail.com
cc083a8dd7020cdfae624bddef86bf96ca3816eb
773f5ab093bac6da0a15af745eb1c2201795bb0d
/SCInfor/source/Logic/Energetics/PowerRelay/EPowerRelayStationState.h
497a7070497c3ef8a7d242f1ca11bb9fafec7048
[]
no_license
jackflower/SCInfor
a5dda83e12f012c94fb3c633b0d3695951815f97
a54191183cc0a6455795d0bc41fd3bb0a2c2972c
refs/heads/master
2021-09-27T15:02:06.098582
2021-09-23T11:16:18
2021-09-23T11:16:18
169,047,909
1
0
null
null
null
null
UTF-8
C++
false
false
776
h
// __________________________________________________________ // | EPowerRelayStationState.h - enumeration of states energy | // | Jack Flower - July 2015 | // |__________________________________________________________| // #ifndef H_POWER_RELAY_STATION_STATE_JACK #define H_POWER_RELAY_STATION_STATE_JACK namespace logic { namespace energetics { /// ///Wyliczenie stanów dla obiektu PowerRelayStation /// enum class EPowerRelayStationState { POWER_RELAY_STATION_DEFAULT = 0, POWER_RELAY_STATION_UPDATE_CONNECTION = 1, POWER_RELAY_STATION_DISCONNECT = 2, POWER_RELAY_STATION_DAMAGE = 3, POWER_RELAY_STATION_DEATHT = 4, }; }//namespace energetics }//namespace logic #endif//H_POWER_RELAY_STATION_STATE_JACK
[ "jackflower@poczta.onet.pl" ]
jackflower@poczta.onet.pl
faff33d9ceab9213796a4c44b693e78341c168dc
117e7c3b88925a338e4400ad5adddab893c1a31a
/src/qt/sendcoinsentry.cpp
06aa24d974c1e1fa820562af62be44477ea44ec5
[ "MIT" ]
permissive
phanngocchien1986/machinecoin-core
4c4df2f63eedc6e3ab49a527237ffb549e0532fb
4fb709ff6df894bdc515b92c5623666f4424b51e
refs/heads/master
2020-03-07T19:47:42.743853
2018-02-28T11:48:28
2018-02-28T11:48:28
127,680,258
1
0
null
2018-04-01T23:40:59
2018-04-01T23:40:59
null
UTF-8
C++
false
false
8,239
cpp
// Copyright (c) 2011-2017 The Machinecoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "sendcoinsentry.h" #include "ui_sendcoinsentry.h" #include "addressbookpage.h" #include "addresstablemodel.h" #include "guiutil.h" #include "optionsmodel.h" #include "platformstyle.h" #include "walletmodel.h" #include <QApplication> #include <QClipboard> SendCoinsEntry::SendCoinsEntry(const PlatformStyle *_platformStyle, QWidget *parent) : QStackedWidget(parent), ui(new Ui::SendCoinsEntry), model(0), platformStyle(_platformStyle) { ui->setupUi(this); ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(":/icons/address-book")); ui->pasteButton->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste")); ui->deleteButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); setCurrentWidget(ui->SendCoins); if (platformStyle->getUseExtraSpacing()) ui->payToLayout->setSpacing(4); #if QT_VERSION >= 0x040700 ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); #endif // normal machinecoin address field GUIUtil::setupAddressWidget(ui->payTo, this); // just a label for displaying machinecoin address(es) ui->payTo_is->setFont(GUIUtil::fixedPitchFont()); // Connect signals connect(ui->payAmount, SIGNAL(valueChanged()), this, SIGNAL(payAmountChanged())); connect(ui->checkboxSubtractFeeFromAmount, SIGNAL(toggled(bool)), this, SIGNAL(subtractFeeFromAmountChanged())); connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked())); connect(ui->deleteButton_is, SIGNAL(clicked()), this, SLOT(deleteClicked())); connect(ui->deleteButton_s, SIGNAL(clicked()), this, SLOT(deleteClicked())); } SendCoinsEntry::~SendCoinsEntry() { delete ui; } void SendCoinsEntry::on_pasteButton_clicked() { // Paste text from clipboard into recipient field ui->payTo->setText(QApplication::clipboard()->text()); } void SendCoinsEntry::on_addressBookButton_clicked() { if(!model) return; AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::SendingTab, this); dlg.setModel(model->getAddressTableModel()); if(dlg.exec()) { ui->payTo->setText(dlg.getReturnValue()); ui->payAmount->setFocus(); } } void SendCoinsEntry::on_payTo_textChanged(const QString &address) { updateLabel(address); } void SendCoinsEntry::setModel(WalletModel *_model) { this->model = _model; if (_model && _model->getOptionsModel()) connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); clear(); } void SendCoinsEntry::clear() { // clear UI elements for normal payment ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked); ui->messageTextLabel->clear(); ui->messageTextLabel->hide(); ui->messageLabel->hide(); // clear UI elements for unauthenticated payment request ui->payTo_is->clear(); ui->memoTextLabel_is->clear(); ui->payAmount_is->clear(); // clear UI elements for authenticated payment request ui->payTo_s->clear(); ui->memoTextLabel_s->clear(); ui->payAmount_s->clear(); // update the display unit, to not use the default ("MAC") updateDisplayUnit(); } void SendCoinsEntry::deleteClicked() { Q_EMIT removeEntry(this); } bool SendCoinsEntry::validate() { if (!model) return false; // Check input validity bool retval = true; // Skip checks for payment request if (recipient.paymentRequest.IsInitialized()) return retval; if (!model->validateAddress(ui->payTo->text())) { ui->payTo->setValid(false); retval = false; } if (!ui->payAmount->validate()) { retval = false; } // Sending a zero amount is invalid if (ui->payAmount->value(0) <= 0) { ui->payAmount->setValid(false); retval = false; } // Reject dust outputs: if (retval && GUIUtil::isDust(ui->payTo->text(), ui->payAmount->value())) { ui->payAmount->setValid(false); retval = false; } return retval; } SendCoinsRecipient SendCoinsEntry::getValue() { // Payment request if (recipient.paymentRequest.IsInitialized()) return recipient; // Normal payment recipient.address = ui->payTo->text(); recipient.label = ui->addAsLabel->text(); recipient.amount = ui->payAmount->value(); recipient.message = ui->messageTextLabel->text(); recipient.fSubtractFeeFromAmount = (ui->checkboxSubtractFeeFromAmount->checkState() == Qt::Checked); return recipient; } QWidget *SendCoinsEntry::setupTabChain(QWidget *prev) { QWidget::setTabOrder(prev, ui->payTo); QWidget::setTabOrder(ui->payTo, ui->addAsLabel); QWidget *w = ui->payAmount->setupTabChain(ui->addAsLabel); QWidget::setTabOrder(w, ui->checkboxSubtractFeeFromAmount); QWidget::setTabOrder(ui->checkboxSubtractFeeFromAmount, ui->addressBookButton); QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); return ui->deleteButton; } void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { recipient = value; if (recipient.paymentRequest.IsInitialized()) // payment request { if (recipient.authenticatedMerchant.isEmpty()) // unauthenticated { ui->payTo_is->setText(recipient.address); ui->memoTextLabel_is->setText(recipient.message); ui->payAmount_is->setValue(recipient.amount); ui->payAmount_is->setReadOnly(true); setCurrentWidget(ui->SendCoins_UnauthenticatedPaymentRequest); } else // authenticated { ui->payTo_s->setText(recipient.authenticatedMerchant); ui->memoTextLabel_s->setText(recipient.message); ui->payAmount_s->setValue(recipient.amount); ui->payAmount_s->setReadOnly(true); setCurrentWidget(ui->SendCoins_AuthenticatedPaymentRequest); } } else // normal payment { // message ui->messageTextLabel->setText(recipient.message); ui->messageTextLabel->setVisible(!recipient.message.isEmpty()); ui->messageLabel->setVisible(!recipient.message.isEmpty()); ui->addAsLabel->clear(); ui->payTo->setText(recipient.address); // this may set a label from addressbook if (!recipient.label.isEmpty()) // if a label had been set from the addressbook, don't overwrite with an empty label ui->addAsLabel->setText(recipient.label); ui->payAmount->setValue(recipient.amount); } } void SendCoinsEntry::setAddress(const QString &address) { ui->payTo->setText(address); ui->payAmount->setFocus(); } bool SendCoinsEntry::isClear() { return ui->payTo->text().isEmpty() && ui->payTo_is->text().isEmpty() && ui->payTo_s->text().isEmpty(); } void SendCoinsEntry::setFocus() { ui->payTo->setFocus(); } void SendCoinsEntry::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update payAmount with the current unit ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); ui->payAmount_is->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); ui->payAmount_s->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); } } bool SendCoinsEntry::updateLabel(const QString &address) { if(!model) return false; // Fill in label from address book, if address has an associated label QString associatedLabel = model->getAddressTableModel()->labelForAddress(address); if(!associatedLabel.isEmpty()) { ui->addAsLabel->setText(associatedLabel); return true; } return false; }
[ "admin@nigho.me" ]
admin@nigho.me
64d7bb00e3b87bf3a7b11f3d2e0124d4ba0b909c
d19435f072ada6f2c01284531d8d6ccdb082a20e
/src/example_parsing.cpp
9f3818972fa0961fcf2868cb790a5355b4c61196
[ "MIT" ]
permissive
danlyke/libfby
cfca91323d67cc3467f14670b1ce651e66282347
c40bec65baf8d3c0d9876ff93d37f67aab670092
refs/heads/master
2020-12-25T16:51:18.767081
2016-09-16T17:37:53
2016-09-16T17:37:53
39,160,441
0
0
null
null
null
null
UTF-8
C++
false
false
1,256
cpp
#include <sys/types.h> #include <string.h> #include <stdio.h> #include <locale.h> #include <iostream> #include <fstream> #include <map> #include "fbyregexparser.h" using namespace std; using namespace Fby; const char test_contents[] = "This is a <em>line</em> of text\n" "\n" "<blockquote>This is an indented line of text</blockquote>\n" "\n" "This is an unindented line of text\n" "\n"; class TestTreeBuilder : public TreeBuilder { public: TestTreeBuilder() : TreeBuilder() {}; virtual ~TestTreeBuilder() {} ParseTreeNode *NodeFactory(const std::string & nodename) { return new ElementNode(nodename); } }; int main(int argc, char** argv) { setlocale(LC_ALL, ""); /* Use system locale instead of default "C" */ TestTreeBuilder tree_builder; { MarkedUpTextParser parser; parser.Parse(tree_builder, test_contents, sizeof(test_contents) - 1); } cout << "Parsed" << endl; tree_builder.ForEach([](ParseTreeNodePtr n, int depth) { for (int i = 0; i < depth; ++i) cout << " "; cout << n->Name() << endl; }); }
[ "danlyke@flutterby.com" ]
danlyke@flutterby.com
3d8141852cb6d35e17a6b31b709901067a513175
17c51516399d4170cc970260a32ccb79b7e77c32
/solved/DFS와BFS/1260.cpp
436de17030344bc0d91d35c05e5d4081702ad30d
[]
no_license
heosang/BJ_solution
2037281e74eb4d4591d5659936fe02291cfea83f
7143eecd0bc772ec08247395397063ee5b77555b
refs/heads/master
2021-02-04T15:06:33.494190
2020-05-30T14:37:52
2020-05-30T14:37:52
243,676,294
0
0
null
null
null
null
UTF-8
C++
false
false
901
cpp
#include <iostream> #include <stack> #include <queue> #include <vector> #include <algorithm> using namespace std; int adj[1001][1001]; queue <int> q; void dfs(int); void bfs(int); bool visit[1001] = { 0 ,}; int n, m, v; int main() { cin >> n >> m >> v; int a, b; for (int i = 0;i < m;i++) { cin >> a >> b; adj[a][b]=1; adj[b][a]=1; } dfs(v); for (int i = 1;i <= n;i++) { visit[i] = false; } cout << "\n"; bfs(v); } void dfs(int v) { visit[v] = true; cout << v << " "; for (int i = 1;i <= n;i++) { if (adj[v][i] == 1 && visit[i] == false) { visit[i] = true; dfs(i); } } return; } void bfs(int v) { q.push(v); visit[v] = true; while (1) { if (q.empty()) { break; } int temp = q.front(); q.pop(); cout << temp << " "; for (int i = 1;i <= n;i++) { if (adj[temp][i] == 1 && visit[i] == false) { visit[i] = true; q.push(i); } } } return; }
[ "57525618+heosang@users.noreply.github.com" ]
57525618+heosang@users.noreply.github.com
c9733af7641a8d2e69da097ae85442e5d342eb8e
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/collectd/gumtree/collectd_repos_function_1391_collectd-5.6.1.cpp
e6f2b49d5c1a1552a98267e788c9628ae9728226
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,068
cpp
static int dns_init (void) { /* clean up an old thread */ int status; pthread_mutex_lock (&traffic_mutex); tr_queries = 0; tr_responses = 0; pthread_mutex_unlock (&traffic_mutex); if (listen_thread_init != 0) return (-1); status = plugin_thread_create (&listen_thread, NULL, dns_child_loop, (void *) 0); if (status != 0) { char errbuf[1024]; ERROR ("dns plugin: pthread_create failed: %s", sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } listen_thread_init = 1; #if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_NET_RAW) if (check_capability (CAP_NET_RAW) != 0) { if (getuid () == 0) WARNING ("dns plugin: Running collectd as root, but the CAP_NET_RAW " "capability is missing. The plugin's read function will probably " "fail. Is your init system dropping capabilities?"); else WARNING ("dns plugin: collectd doesn't have the CAP_NET_RAW capability. " "If you don't want to run collectd as root, try running \"setcap " "cap_net_raw=ep\" on the collectd binary."); } #endif return (0); }
[ "993273596@qq.com" ]
993273596@qq.com
5c49a73e3d5a06df00b3c91daaeed4de8d26288c
c8724f08b9630a5051d1bce673127da5bd93d861
/microsoft/76.cpp
94d3d7dd7dcb8c2c8845510a918ffafae064a4fb
[]
no_license
codelibra/comp-programming
89b2b2b656d317b52d2c2427ad11aa21d509c0e9
fce68180a8f1e68a2a6503bf450a524b41de02d5
refs/heads/master
2021-01-21T17:39:17.618853
2017-06-04T16:06:53
2017-06-04T16:06:53
91,977,761
1
1
null
null
null
null
UTF-8
C++
false
false
714
cpp
//shivi..coding is adictive!! //median of two sorted arrays #include<shiviheaders.h> using namespace std; int median(int arr[],int n) { if(n%2==0) return (arr[n/2]+arr[n/2-1])/2; else return arr[n/2]; } int GetMedian(int arr1[],int arr2[],int n) { if(n==0) return -1; if(n==1) return arr1[n]; if(n==2) return (max(arr1[0],arr2[0])+min(arr1[1],arr2[1]))/2; int m1,m2; m1=median(arr1,n); m2=median(arr2,n); if(m1==m2) return m1; if(m1>m2) { if(n%2==0) return GetMedian(arr1,arr2+n/2-1,n-n/2+1); else return GetMedian(arr1,arr2+n/2,n/2); } else { if(n%2==0) return GetMedian(arr1+n/2-1,arr2,n-n/2+1); else return GetMedian(arr1+n/2,arr2,n/2); } } int main() { }
[ "trivedi.akshay3@gmail.com" ]
trivedi.akshay3@gmail.com
ddc74404d80e0be85d9187a9aeac7fd5ca3aec73
d4b733f2e00b5d0ab103ea0df6341648d95c993b
/src/c-cpp/include/sst/catalog/is_zero.hpp
5826328773ab082aa6720b5ea3fe51b9736253ab
[ "MIT" ]
permissive
stealthsoftwareinc/sst
ad6117a3d5daf97d947862674336e6938c0bc699
f828f77db0ab27048b3204e10153ee8cfc1b2081
refs/heads/master
2023-04-06T15:21:14.371804
2023-03-24T08:30:48
2023-03-24T08:30:48
302,539,309
1
0
null
null
null
null
UTF-8
C++
false
false
1,741
hpp
// // Copyright (C) 2012-2023 Stealth Software Technologies, Inc. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: // // The above copyright notice and this permission notice (including // the next paragraph) shall be included in all copies or // substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // // SPDX-License-Identifier: MIT // #ifndef SST_CATALOG_IS_ZERO_HPP #define SST_CATALOG_IS_ZERO_HPP #include <sst/catalog/enable_if_t.hpp> #include <sst/catalog/is_integer.hpp> namespace sst { //---------------------------------------------------------------------- template<class X, sst::enable_if_t<sst::is_integer<X>::value> = 0> constexpr bool is_zero(X const x) noexcept { return x == static_cast<X>(0); } //---------------------------------------------------------------------- } // namespace sst #endif // #ifndef SST_CATALOG_IS_ZERO_HPP
[ "sst@stealthsoftwareinc.com" ]
sst@stealthsoftwareinc.com
25a06ccb2ee9273360a5c5667e94dbe7bf4571f3
d69cc85c6d1039c64112432b22a1a756b267b1a8
/_cmake/lib/arduino-upm/src/rfr359f.hpp
eeb95dc9c3a37334a0b56341812a0baa74c623a1
[ "MIT" ]
permissive
SSG-DRD-IOT/lab-protocols-mqtt-arduino
02a004f60fcdd8da65d221dc287f26e3a016afa1
834cef842154b4645f98f1f7da57cb0ea887ca98
refs/heads/master
2021-01-19T07:54:17.220914
2018-04-03T16:11:34
2018-04-03T16:11:34
100,647,409
0
4
MIT
2018-04-03T16:11:35
2017-08-17T21:40:18
C
UTF-8
C++
false
false
2,453
hpp
/* * Author: Jon Trulson <jtrulson@ics.com> * Copyright (c) 2015 Intel Corporation. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include <string> #include <mraa/gpio.h> namespace upm { /** * @brief RFR359 Distance Interrupter library * @defgroup rfr359f libupm-rfr359f * @ingroup seeed gpio light robok tsk */ /** * @library rfr359f * @sensor rfr359f * @comname Infrared Distance Interrupter * @altname Grove Distance Interrupter * @type light * @man seeed * @web https://www.seeedstudio.com/Grove-IR-Distance-Interrupter-p-1278.html * @con gpio * @kit robok tsk * * @brief API for the RFR359F-based Grove Distance Interrupter. * * UPM module for the Grove distance interrupter. The sensitivity * can be adjusted with the potentiometer on the sensor module. It * has a range of approximately 4 inches and a quick response time. * * @image html rfr359f.jpg * @snippet rfr359f.cxx Interesting */ class RFR359F { public: /** * RFR359F constructor * * @param pin Digital pin to use */ RFR359F(int pin); /** * RFR359F destructor */ ~RFR359F(); /** * Gets the status of the pin; true means an object has been detected * * @return True if the sensor has detected an object */ bool objectDetected(); private: mraa_gpio_context m_gpio; }; }
[ "christopherx.crase@intel.com" ]
christopherx.crase@intel.com
1fa6ad4a47d0ce6884946cb418a3acb26dfeba7a
335099e4850cb84edb059c671ced5ded847c7e10
/source/render/sprite.h
0280e5974908ec48e8a61e5fb5610e41eae239c4
[ "Zlib" ]
permissive
dmdware/sfh
a260bf771d0017a397f54219f37fb1ea7eb86e87
b7b0bf71634b864645e04effd8c745696c454d7c
refs/heads/master
2021-01-17T10:40:27.407838
2016-12-10T03:25:20
2016-12-10T03:25:20
38,033,367
0
0
null
null
null
null
UTF-8
C++
false
false
2,091
h
#ifndef SPRITE_H #define SPRITE_H #include "../texture.h" class Sprite { public: Sprite(); ~Sprite(); void free(); bool on; uint32_t difftexi; uint32_t teamtexi; uint32_t depthtexi; uint32_t elevtexi; float offset[4]; //the pixel texture coordinates centered around a certain point, for use for vertex positions when not cropping (old) float crop[4]; //the texture coordinates [0..1] of the cropped sprite, used for the texture coords float cropoff[4]; //the pixel texture coordinates of the cropped sprite, used for vertex positions LoadedTex* pixels; std::string fullpath; }; //#define SPRITES 4096 #define SPRITES 16096 extern Sprite g_sprite[SPRITES]; class SpList { public: bool on; bool inclines; bool sides; int32_t nsides; bool rotations; bool frames; int32_t nframes; int32_t nslices; std::string fullpath; int nsp; uint32_t* sprites; void free() { nsp = 0; delete [] sprites; sprites = NULL; on = false; nslices = 1; } SpList() { nsp = 0; sprites = NULL; on = false; nslices = 1; } ~SpList() { free(); } }; #define SPRITELISTS 256 extern SpList g_splist[SPRITELISTS]; class SpriteToLoad { public: std::string relative; uint32_t* spindex; bool loadteam; bool loaddepth; }; extern std::vector<SpriteToLoad> g_spriteload; extern int32_t g_lastLSp; bool Load1Sprite(); void FreeSprites(); bool LoadSprite(const char* relative, uint32_t* spindex, bool loadteam, bool loaddepth); void QueueSprite(const char* relative, uint32_t* spindex, bool loadteam, bool loaddepth); void ParseSprite(const char* relative, Sprite* s); bool PlayAnim(float& frame, int32_t first, int32_t last, bool loop, float rate); bool PlayAnimB(float& frame, int32_t first, int32_t last, bool loop, float rate); //Play animation backwards int32_t SpriteRef(SpList* sl, int32_t frame, int32_t incline, int32_t pitch, int32_t yaw, int32_t roll, int slicex, int slicey); bool LoadSpriteList(const char* relative, uint32_t* splin, bool loadteam, bool loaddepth, bool queue); int32_t NewSpriteList(); int32_t NewSprite(); #endif
[ "polyfrag@hotmail.com" ]
polyfrag@hotmail.com
85cfbeea9c8a1f2884c93e15ab98b7f8721754cd
d23653b77dcce985c72e42e6496263fbeb2c1dd8
/qrisp/recurrences_test.cc
d034dcb59bfd784ce18bea0173e99bed60125757
[ "Apache-2.0" ]
permissive
google/qrisp
0dcd8cd7662ab3b4eb5aae4ff0d232d3d48c94ab
1970d13166cddcd05cb10fccdb34247c7b0dddf3
refs/heads/master
2023-08-05T05:39:40.889920
2016-03-07T20:16:25
2016-03-07T20:16:25
47,629,106
12
12
null
2022-10-04T23:39:34
2015-12-08T14:59:43
C++
UTF-8
C++
false
false
19,032
cc
// Copyright 2014 Google Inc.All Rights Reserved. // // Licensed under the Apache License, // Version 2.0(the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "recurrences.h" #include <algorithm> #include <cmath> #include <string> #include <gtest/gtest.h> #include "learning-utils.h" #include "model.h" #include "third_party/googleflags/include/gflags/gflags.h" #include "utils.h" DECLARE_bool(enable_quality_features); namespace qrisp { namespace { using fdb::learning::CalculateSparseScalarProduct; constexpr const float kEpsilon = 1e-6; class RecurrencesTest : public testing::Test { protected: RecurrencesTest() {} ~RecurrencesTest() {} // virtual void SetUp() will be called before each test is run. You // should define it if you need to initialize the varaibles. // Otherwise, this can be skipped. virtual void SetUp() {} virtual void TearDown() {} }; TEST_F(RecurrencesTest, InitTables) { uint32_t table_size = 10; // Create and fill dynamic programming tables. DPTable score(NUM_STATES, table_size, table_size, LOG_ZERO); DPTable traceback(NUM_STATES, table_size, table_size, LOG_ZERO); for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { EXPECT_NEAR(score(i, j, k), LOG_ZERO, kEpsilon); EXPECT_NEAR(traceback(i, j, k), LOG_ZERO, kEpsilon); } } } } TEST_F(RecurrencesTest, UpdateTables) { idx_t table_size = 4; // Create and fill dynamic programming tables. DPTable score(NUM_STATES, table_size, table_size, LOG_ZERO); DPTable traceback(NUM_STATES, table_size, table_size, LOG_ZERO); for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { EXPECT_NEAR(score(i, j, k), LOG_ZERO, kEpsilon); EXPECT_NEAR(traceback(i, j, k), LOG_ZERO, kEpsilon); } } } for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { double new_score = (i + j) % 2 == 0 ? k * 1.0 : k * -1.0; double new_trace = (i + j) % 2 == 0 ? 55.0 : 2.0; UpdateMax(&score, &traceback, i, j, k, new_score, new_trace); } } } for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { EXPECT_NEAR(score(i, j, k), (i + j) % 2 == 0 ? k * 1.0 : k * -1.0, kEpsilon); EXPECT_NEAR(traceback(i, j, k), (i + j) % 2 == 0 ? 55.0 : 2.0, kEpsilon); } } } for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { double new_score = (i + j) % 2 == 0 ? k * 10.0 : k * -0.1; double new_trace = (i + j) % 2 == 0 ? 33.0 : 4.0; UpdateMax(&score, &traceback, i, j, k, new_score, new_trace); } } } for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { if (k > 0) { EXPECT_NEAR(score(i, j, k), (i + j) % 2 == 0 ? k * 10.0 : k * -0.1, kEpsilon); EXPECT_NEAR(traceback(i, j, k), (i + j) % 2 == 0 ? 33.0 : 4.0, kEpsilon); } else { EXPECT_NEAR(score(i, j, k), (i + j) % 2 == 0 ? k * 1.0 : k * -1.0, kEpsilon); EXPECT_NEAR(traceback(i, j, k), (i + j) % 2 == 0 ? 55.0 : 2.0, kEpsilon); } } } } } TEST_F(RecurrencesTest, UpdateTablesViaFunctor) { uint32_t table_size = 4; // Create and fill dynamic programming tables. DPTable score(NUM_STATES, table_size, table_size, LOG_ZERO); DPTable traceback(NUM_STATES, table_size, table_size, LOG_ZERO); for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { EXPECT_NEAR(score(i, j, k), LOG_ZERO, kEpsilon); EXPECT_NEAR(traceback(i, j, k), LOG_ZERO, kEpsilon); } } } auto UPDATE = bind(UpdateMax, &score, &traceback, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5); for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { double new_score = (i + j) % 2 == 0 ? k * 1.0 : k * -1.0; double new_trace = (i + j) % 2 == 0 ? 55.0 : 2.0; UPDATE(i, j, k, new_score, new_trace); } } } for (idx_t i = 0; i < NUM_STATES; i++) { for (idx_t j = 0; j < table_size; j++) { for (idx_t k = 0; k < table_size; k++) { EXPECT_NEAR(score(i, j, k), (i + j) % 2 == 0 ? k * 1.0 : k * -1.0, kEpsilon); EXPECT_NEAR(traceback(i, j, k), (i + j) % 2 == 0 ? 55.0 : 2.0, kEpsilon); } } } } TEST_F(RecurrencesTest, LossFunctor) {} TEST_F(RecurrencesTest, EncodeDecodeTraceback) { const idx_t rna_size = 19; { idx_t i = 3; idx_t j = 15; score_t enc_tb = EncodeTraceback(i, j, rna_size); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size); EXPECT_EQ(i, ip); EXPECT_EQ(j, jp); } { score_t enc_tb = EncodeTraceback(0, 0, rna_size); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size); EXPECT_EQ(0, ip); EXPECT_EQ(0, jp); } { score_t enc_tb = EncodeTraceback(1, 0, rna_size); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size); EXPECT_EQ(1, ip); EXPECT_EQ(0, jp); } const idx_t rna_size_2 = 12; { score_t enc_tb = EncodeTraceback(2, 0, rna_size_2); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size_2); EXPECT_EQ(2, ip); EXPECT_EQ(0, jp); } { score_t enc_tb = EncodeTraceback(0, 0, rna_size_2); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size_2); EXPECT_EQ(0, ip); EXPECT_EQ(0, jp); } { score_t enc_tb = EncodeTraceback(1, 0, rna_size_2); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size_2); EXPECT_EQ(1, ip); EXPECT_EQ(0, jp); } { score_t enc_tb = EncodeTraceback(2, 0, rna_size); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size); EXPECT_EQ(2, ip); EXPECT_EQ(0, jp); } { score_t enc_tb = EncodeTraceback(3, 11, rna_size); idx_t ip; idx_t jp; std::tie(ip, jp) = DecodeTraceback(enc_tb, rna_size); EXPECT_EQ(3, ip); EXPECT_EQ(11, jp); } } TEST_F(RecurrencesTest, FillTables) { Structure rna(".......", "ACTCACT", {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); const idx_t rna_size = rna.Size(); // Create and fill dynamic programming tables. DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FeatureVec model; CalculateFeatures(rna, &model); FillTables(rna, vmode, loss_factor, model, scores, traceback); delete scores; delete traceback; } TEST_F(RecurrencesTest, PerformTraceback) { vector<score_t> q(19, 0.0); Structure rna("...(((....)))......", "ACCATCTCCCGAACCAGCT", q); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); const DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FeatureVec model; CalculateFeatures(rna, &model); FillTables(rna, vmode, loss_factor, model, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); delete scores; delete traceback; // EXPECT_NEAR(196.0, scores.Get(DO_OUTER, 0, rna_size - 1), kEpsilon); } TEST_F(RecurrencesTest, DecodeBestPath) { vector<score_t> q(19, 0.0); Structure rna("...(((....)))......", "ACCATCTCCCGAACCAGCT", q); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; CalculateFeatures(rna, &model); const DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FillTables(rna, vmode, loss_factor, model, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); string brackets; PairingsToBrackets(result, &brackets); Structure dec_rna(brackets, "ACCATCTCCCGAACCAGCT", q); FeatureVec features; CalculateFeatures(dec_rna, &features); // cout << "score best path: " << scores->Get(DO_OUTER, 0, rna_size - 1) << // endl; // cout << "score scalar product: " << CalculateSparseScalarProduct(model, // features) << endl; delete scores; delete traceback; } // for (int s = 0; s < NUM_STATES; s++) { // for (int i = 0; i < traceback->GetSize2(); i++) { // for (int j = 0; j < traceback->GetSize3(); j++) { // if (traceback->Get(s, i, j) >= 0) { // int p, k; // std::tie(p, k) = DecodeTraceback(traceback->Get(s, i, j), rna_size); // ASSERT_GE(p, 0); // ASSERT_GE(k, 0); // ASSERT_LE(p, rna_size); // ASSERT_LE(k, rna_size); // } // } // } // } TEST_F(RecurrencesTest, DecodeBestPathRandShort) { Structure rna(".......", "ACCCTTA", {}); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; int ctr = 1; auto GetValue = [&ctr]() { return drand48(); }; for (int i = 0; i < 906; i++) { model.insert(make_pair(i, GetValue())); } const DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FeatureVec model_transformed = model; InitializeFeatures(&model_transformed); FillTables(rna, vmode, loss_factor, model_transformed, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); vector<idx_t> index(result.size(), 0); int count = 0; for_each(index.begin(), index.end(), [&count](idx_t& i) { return i = count++; }); // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << index[i] << " "; //} // cout << endl; // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << result[i] << " "; //} // cout << endl; string brackets; PairingsToBrackets(result, &brackets); Structure dec_rna(brackets, "ACCCTTA", {}); FeatureVec features; CalculateFeatures(dec_rna, &features); EXPECT_EQ(scores->Get(DO_OUTER, 0, rna_size - 1), CalculateSparseScalarProduct(model, features)); delete scores; delete traceback; } TEST_F(RecurrencesTest, DecodeBestPathRand) { // Structure rna("...(((....)))......", // "ACCATCTCCCGAACCAGCT"); Structure rna("............", "ACCTTTTTTATT", {}); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; int ctr = 1; auto GetValue = [&ctr]() { return drand48(); }; for (int i = 0; i < 906; i++) { model.insert(make_pair(i, GetValue())); } const DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FeatureVec model_transformed = model; InitializeFeatures(&model_transformed); FillTables(rna, vmode, loss_factor, model_transformed, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); vector<idx_t> index(result.size(), 0); int count = 0; for_each(index.begin(), index.end(), [&count](idx_t& i) { return i = count++; }); // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << index[i] << " "; //} // cout << endl; // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << result[i] << " "; //} // cout << endl; string brackets; PairingsToBrackets(result, &brackets); // Structure dec_rna(brackets, "ACCATCTCCCGAACCAGCT"); Structure dec_rna(brackets, "ACCTTTTTTATT", {}); FeatureVec features; CalculateFeatures(dec_rna, &features); // cout << "Brackets: " << brackets << endl; // cout << "Score best path / scalar prod.: " << scores->Get(DO_OUTER, 0, // rna_size - 1) // << " " // << CalculateSparseScalarProduct(model, features) // << endl; EXPECT_NEAR(scores->Get(DO_OUTER, 0, rna_size - 1), CalculateSparseScalarProduct(model, features), kEpsilon); delete scores; delete traceback; } TEST_F(RecurrencesTest, DecodeBestPathRandWithLoss) { // Structure rna("...(((....)))......", // "ACCATCTCCCGAACCAGCT"); Structure rna("............", "ACCTTTTTTATT", {}); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; int ctr = 1; auto GetValue = [&ctr]() { return drand48(); }; for (int i = 0; i < 906; i++) { model.insert(make_pair(i, GetValue())); } const DECODING_MODE vmode = LOSS_ENABLED; const score_t loss_factor = 1.0; FeatureVec model_transformed = model; InitializeFeatures(&model_transformed); FillTables(rna, vmode, loss_factor, model_transformed, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); vector<idx_t> index(result.size(), 0); int count = 0; for_each(index.begin(), index.end(), [&count](idx_t& i) { return i = count++; }); for (idx_t i = 1; i < index.size(); i++) { cout << setw(3) << index[i] << " "; } cout << endl; for (idx_t i = 1; i < index.size(); i++) { cout << setw(3) << result[i] << " "; } cout << endl; string brackets; PairingsToBrackets(result, &brackets); // Structure dec_rna(brackets, "ACCATCTCCCGAACCAGCT"); Structure dec_rna(brackets, "ACCTTTTTTATT", {}); score_t loss = HammingLoss(rna, dec_rna); FeatureVec features; CalculateFeatures(dec_rna, &features); // cout << "Brackets: " << brackets << endl; // cout << "Score best path / scalar prod.: " << scores->Get(DO_OUTER, 0, // rna_size - 1) // << " " // << CalculateSparseScalarProduct(model, features) + loss // << endl; EXPECT_NEAR(scores->Get(DO_OUTER, 0, rna_size - 1), CalculateSparseScalarProduct(model, features) + loss, kEpsilon); delete scores; delete traceback; } TEST_F(RecurrencesTest, DecodeBestPathRandLarge) { Structure rna("...(((....)))......", "ACCATCTCCCGAACCAGCT", {}); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; int ctr = 1; auto GetValue = [&ctr]() { return drand48(); }; for (idx_t i = 0; i < 906; i++) { model.insert(make_pair(i, GetValue())); } const DECODING_MODE vmode = LOSS_DISABLED; const score_t loss_factor = 1.0; FeatureVec model_transformed = model; InitializeFeatures(&model_transformed); FillTables(rna, vmode, loss_factor, model_transformed, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); vector<idx_t> index(result.size(), 0); int count = 0; for_each(index.begin(), index.end(), [&count](idx_t& i) { return i = count++; }); // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << index[i] << " "; //} // cout << endl; // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << result[i] << " "; //} // cout << endl; string brackets; PairingsToBrackets(result, &brackets); cout << brackets << endl; Structure dec_rna(brackets, "ACCATCTCCCGAACCAGCT", {}); FeatureVec features; CalculateFeatures(dec_rna, &features); // cout << "Brackets: " << brackets << endl; // cout << "Score best path / scalar prod.: " << scores->Get(DO_OUTER, 0, // rna_size - 1) // << " " // << CalculateSparseScalarProduct(model, features) // << endl; EXPECT_NEAR(scores->Get(DO_OUTER, 0, rna_size - 1), CalculateSparseScalarProduct(model, features), kEpsilon); delete scores; delete traceback; } TEST_F(RecurrencesTest, DecodeBestPathRandLargeLoss) { Structure rna("...(((....)))......", "ACCATCTCCCGAACCAGCT", {}); const idx_t rna_size = rna.Size(); DPTable* scores = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); DPTable* traceback = new DPTable(NUM_STATES, rna_size, rna_size, LOG_ZERO); FeatureVec model; int ctr = 1; auto GetValue = [&ctr]() { return drand48(); }; for (idx_t i = 0; i < 906; i++) { model.insert(make_pair(i, GetValue())); } const DECODING_MODE vmode = LOSS_ENABLED; const score_t loss_factor = 1.0; FeatureVec model_transformed = model; InitializeFeatures(&model_transformed); FillTables(rna, vmode, loss_factor, model_transformed, scores, traceback); vector<idx_t> result; PerformTraceback(*traceback, rna_size, &result); vector<idx_t> index(result.size(), 0); int count = 0; for_each(index.begin(), index.end(), [&count](idx_t& i) { return i = count++; }); // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << index[i] << " "; //} // cout << endl; // for (int i = 1; i < index.size(); i++) { // cout << setw(3) << result[i] << " "; //} // cout << endl; string brackets; PairingsToBrackets(result, &brackets); Structure dec_rna(brackets, "ACCATCTCCCGAACCAGCT", {}); score_t loss = HammingLoss(rna, dec_rna); FeatureVec features; CalculateFeatures(dec_rna, &features); // cout << "Brackets: " << brackets << endl; // cout << "Score best path / scalar prod.: " << scores->Get(DO_OUTER, 0, // rna_size - 1) // << " " // << CalculateSparseScalarProduct(model, features) + loss // << endl; EXPECT_NEAR(scores->Get(DO_OUTER, 0, rna_size - 1), CalculateSparseScalarProduct(model, features) + loss, kEpsilon); delete scores; delete traceback; } } // namespace } // namespace qrisp int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
[ "fdb@google.com" ]
fdb@google.com
f65e172ffb32453101dd9db7e26a37a0f7a50b9b
70ac93d02bd71c2a2b007a1bad346756d73ef126
/labs/hw3/3.2.grades_rank.cpp
da30d52e3b9ab236e977b36e48cc3887d4fb0722
[ "MIT" ]
permissive
USTC-CS-Course-Resource/Algorithm-HWs-and-Labs
24fe5e2f0ca5b1598e92d5c61e9db0e831c5389e
e77093631437bfb412d39ae1aeb5679bfe8b96ca
refs/heads/main
2023-04-22T05:09:36.387335
2021-05-16T07:15:39
2021-05-16T07:15:39
304,485,769
4
0
null
null
null
null
UTF-8
C++
false
false
1,445
cpp
#include <iostream> using namespace std; constexpr int MAX_id = 2500000; constexpr int MAX_GRADE = 100; class Student { public: int math; int english; int sum; int id; Student() {}; bool operator>= (const Student &s) { if (this->sum > s.sum) return true; else if (this->sum == s.sum) { if (this->math > s.math) return true; else if (this->math == s.math) { if (this->id >= s.id) return true; } } return false; } }; void quick_sort(Student **array, int start, int end) { // partition if (start >= end) return; Student pivot = *array[end]; int i = start - 1; for (int j = start; j < end; j++) { if (*array[j] >= pivot) { i++; swap<Student*>(array[i], array[j]); } } i++; // now i refers to pivot element swap<Student*>(array[i], array[end]); // recurse quick_sort(array, start, i-1); quick_sort(array, i+1, end); } int main() { int n; scanf("%d", &n); Student **students = new Student*[n]; for (int i = 0; i < n; i++) { students[i] = new Student(); scanf("%d %hhd %hhd", &students[i]->id, &students[i]->math, &students[i]->english); students[i]->sum = students[i]->math + students[i]->english; } quick_sort(students, 0, n-1); for (int i = 0; i < n; i++) printf("%d ", students[i]->id); }
[ "895650485@qq.com" ]
895650485@qq.com
064f0676238c3046db25bf0e664f36b7ff2e7dfb
8d8ffcf660fa7e7399ba33b5acab58e362598d47
/NavigationAndControl/MOOSTaskLib/LimitBox.cpp
b12f18b9a94e86eb0b17d25ad9d06a6c5c03db7e
[]
no_license
alod83/IS-MOOS
e0d33102f57264fdbba0db6a32553273a054d604
1b7b256ab2edc3224d431dc718476e80341da105
refs/heads/master
2020-03-27T23:49:45.731438
2018-09-04T13:33:04
2018-09-04T13:33:04
147,350,574
2
0
null
null
null
null
UTF-8
C++
false
false
6,349
cpp
/////////////////////////////////////////////////////////////////////////// // // MOOS - Mission Oriented Operating Suite // // A suit of Applications and Libraries for Mobile Robotics Research // Copyright (C) 2001-2005 Massachusetts Institute of Technology and // Oxford University. // // This software was written by Paul Newman and others // at MIT 2001-2002 and Oxford University 2003-2005. // email: pnewman@robots.ox.ac.uk. // // This file is part of a MOOS Basic (Common) Application. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. // ////////////////////////// END_GPL ////////////////////////////////// // LimitBox.cpp: implementation of the CLimitBox class. // ////////////////////////////////////////////////////////////////////// #include "LimitBox.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// #define DEFAULT_BOX_X 500 #define DEFAULT_BOX_Y 500 #define DEFAULT_BOX_DEPTH 20 #define DEFAULT_IGNORE_TIME 10.0 #define ON_BOX_EXCEEDED_ELEVATOR MOOSDeg2Rad(-30.00) CLimitBox::CLimitBox() { m_dfXMax = DEFAULT_BOX_X; m_dfXMin = -DEFAULT_BOX_X; m_dfYMax = DEFAULT_BOX_Y; m_dfYMin = -DEFAULT_BOX_Y; m_dfDepthMax = DEFAULT_BOX_DEPTH; m_dfIgnoreTime = DEFAULT_IGNORE_TIME; m_bWatching = false; m_dfWatchStart = 0; m_nPriority = 0; m_bDoneVerbalNotify = false; } CLimitBox::~CLimitBox() { } bool CLimitBox::SetParam(string sParam, string sVal) { MOOSToUpper(sParam); MOOSToUpper(sVal); if(!CMOOSBehaviour::SetParam(sParam,sVal)) { //alwasy make it very important m_nPriority = 0; //this is for us... if(MOOSStrCmp(sParam,"XMIN")) { m_dfXMin=atof(sVal.c_str()); } else if(MOOSStrCmp(sParam,"XMAX")) { m_dfXMax=atof(sVal.c_str()); } else if(MOOSStrCmp(sParam,"YMIN")) { m_dfYMin=atof(sVal.c_str()); } else if(MOOSStrCmp(sParam,"YMAX")) { m_dfYMax=atof(sVal.c_str()); } else if(MOOSStrCmp(sParam,"DEPTHMAX")) { m_dfDepthMax=atof(sVal.c_str()); } else if(MOOSStrCmp(sParam,"IGNORETIME")) { m_dfIgnoreTime=atof(sVal.c_str()); } else { MOOSTrace("CLimitBox::unknown param %s",sParam.c_str()); return false; } } return true; } //returns false if we haven't received data in a while..bad news! bool CLimitBox::RegularMailDelivery(double dfTimeNow) { return (!m_DepthDOF.IsStale(dfTimeNow,GetStartTime())&& !m_XDOF.IsStale(dfTimeNow,GetStartTime()) && !m_YDOF.IsStale(dfTimeNow,GetStartTime())); } bool CLimitBox::Run(CPathAction &DesiredAction) { if(m_DepthDOF.IsValid()) { if(m_DepthDOF.IsValid() && m_DepthDOF.GetCurrent()>m_dfDepthMax || m_XDOF.IsValid() && m_XDOF.GetCurrent()>m_dfXMax || m_XDOF.IsValid() && m_XDOF.GetCurrent()<m_dfXMin || m_YDOF.IsValid() && m_YDOF.GetCurrent()>m_dfYMax || m_YDOF.IsValid() && m_YDOF.GetCurrent()<m_dfYMin) { if(m_bWatching == false) { m_bWatching = true; m_dfWatchStart = MOOSTime(); } else { if(MOOSTime()-m_dfWatchStart>m_dfIgnoreTime) { DesiredAction.Set( ACTUATOR_ELEVATOR, ON_BOX_EXCEEDED_ELEVATOR, m_nPriority, "Bounding Box"); DesiredAction.Set( ACTUATOR_THRUST, 0, m_nPriority, "Bounding Box"); DesiredAction.Set( ACTUATOR_RUDDER, 0, m_nPriority, "Bounding Box"); //we may have some flags to set... string sTxt = MOOSFormat("Box Limits exceeded for more than %f seconds",m_dfIgnoreTime); OnEvent(sTxt,!m_bDoneVerbalNotify); m_bDoneVerbalNotify = true; } } } else { m_bDoneVerbalNotify = false; m_bWatching = false; } } return true; } bool CLimitBox::OnNewMail(MOOSMSG_LIST &NewMail) { CMOOSMsg Msg; if(PeekMail(NewMail,"NAV_X",Msg)) { if(!Msg.IsSkewed(GetTimeNow())) { m_XDOF.SetCurrent(Msg.m_dfVal,Msg.m_dfTime); } } if(PeekMail(NewMail,"NAV_Y",Msg)) { if(!Msg.IsSkewed(GetTimeNow())) { m_YDOF.SetCurrent(Msg.m_dfVal,Msg.m_dfTime); } } if(PeekMail(NewMail,"NAV_DEPTH",Msg)) { if(!Msg.IsSkewed(GetTimeNow())) { m_DepthDOF.SetCurrent(Msg.m_dfVal,Msg.m_dfTime); } } //always call base class version CMOOSBehaviour::OnNewMail(NewMail); return true; } bool CLimitBox::GetRegistrations(STRING_LIST &List) { List.push_front("NAV_DEPTH"); List.push_front("NAV_X"); List.push_front("NAV_Y"); //always call base class version CMOOSBehaviour::GetRegistrations(List); return true; }
[ "angelica.loduca@iit.cnr.it" ]
angelica.loduca@iit.cnr.it
765e0de4173405df34557978bb9d5af012ee02c4
e28d874a2afa55a8a1c6355b559c6dd73b75f40d
/src/hackerrank/contests/weekofcode/w16/Sprinklers.cpp
70212c6688b270beab65c61a15450a92a5cb358a
[]
no_license
vinorom/contests
e3f4c6ae221ffd6d5b2cbabf45375e74346b99c7
7ae2e77fb486038ca4599f0d1fdde6cba2030a0a
refs/heads/master
2021-06-08T13:22:48.056116
2021-03-27T21:08:42
2021-03-27T21:08:42
33,144,208
0
1
null
null
null
null
UTF-8
C++
false
false
1,957
cpp
/** * https://www.hackerrank.com/contests/w16/challenges/sprinklers */ #include <iostream> #include <vector> using namespace std; int count_sprinklers(int N, const vector<int>& p, int e, vector<int>* pout = 0) { int i = 0; for (; i + 1 < p.size() && p[i+1] - e <= 1; ++i); int count = 1; if (pout) pout->push_back(p[i]); for (; p[i] + e < N; ) { int tmp = i; for (; i + 1 < p.size() && p[i+1] - p[tmp] <= 2 * e + 1; ++i); count++; if (pout) pout->push_back(p[i]); } return count; } void solve(int N, const vector<int>& p, int S, int Q, int& E, vector<int>& pout) { // find minimal possible E E = max(p[0] - 1, N - p.back()); for (int i = 1; i < p.size(); ++i) E = max(E, (p[i] - p[i - 1]) / 2); int opt_cost = (int)p.size() * S + E * Q; for (int e = E; e < N; ) { int count = count_sprinklers(N, p, e); int cost = count * S + e * Q; if (cost < opt_cost) { E = e; opt_cost = cost; } // find next e that gives different number of sprinklers int l = e; int r = N; while (l + 1 < r) { int mid = (l + r) / 2; if (count_sprinklers(N, p, mid) != count) { r = mid; } else { l = mid; } } e = r; } // E is optimal here, find positions to set up sprinklers count_sprinklers(N, p, E, &pout); } int main() { int T; cin >> T; while (T--) { int N, M, S, Q; cin >> N >> M >> S >> Q; vector<int> p(M), pout; for (int i = 0; i < M; ++i) cin >> p[i]; int E; solve(N, p, S, Q, E, pout); cout << pout.size() << " " << E << endl; for (int i = 0; i < pout.size(); ++i) cout << (i > 0 ? " " : "") << pout[i]; cout << endl; } return 0; }
[ "vinogradov.roman@gmail.com" ]
vinogradov.roman@gmail.com
1faf05b889477bdd87ead79a5fbe5f8213a1a0ba
3eb94a5e76e9e346027bdeda9509201f5150205d
/EsbReconstruction/EsbSuperFGD/FgdReconTemplate.cxx
fffb64fc7b194f79284db7ff3ceadc25e91c41e5
[]
no_license
ESSnuSB/EsbRoot
5812ed917315ecec33396efd07b07a4c52300ddb
0a9936406597460cc92907d21fb3a5d1bbff9b28
refs/heads/master
2021-06-11T13:51:14.942802
2021-05-27T07:46:52
2021-05-27T07:46:52
146,453,151
2
3
null
2020-02-21T09:44:19
2018-08-28T13:39:14
C++
UTF-8
C++
false
false
10,425
cxx
#include "EsbReconstruction/EsbSuperFGD/FgdReconTemplate.h" #include "FairLogger.h" #include <fstream> #include <iostream> #include <limits> #include <map> namespace esbroot { namespace reconstruction { namespace superfgd { using namespace std; #define PERMUTATIONS 23 FgdReconTemplate::FgdReconTemplate() { LoadTemplates(); } FgdReconTemplate::~FgdReconTemplate() { } Bool_t FgdReconTemplate::IsLeaf(ReconHit* hit) { Bool_t isHitLeaf(false); if(hit->fAllHits.size()==1) { LOG(debug)<< "Single leaf " << hit->fLocalId; isHitLeaf = true; } else { Int_t permutation(0); std::vector<TVector3> vecs; GetHitVectors(hit, vecs); for(size_t temp=0; !isHitLeaf && temp < fLeafVectors.size(); ++temp) { if(fLeafVectors[temp].hitVectors.size() == hit->fAllHits.size()) { std::vector<TVector3>& tempVecs = fLeafVectors[temp].hitVectors; isHitLeaf = AreVectorsEqual(tempVecs, vecs, permutation); } } if(isHitLeaf) { LOG(debug) << "Leaf " << hit->fLocalId << " with local hits " << hit->fAllHits.size() << endl; } } return isHitLeaf; } Bool_t FgdReconTemplate::GetNextHit(ReconHit* previous, ReconHit* current, ReconHit*& next) { Bool_t nextFound(false); next = nullptr; if(current==nullptr) { throw "Invalid current hit"; } if(current->fAllHits.empty()) { return nextFound; } Int_t previousId = (previous==nullptr) ? -1 : previous->fLocalId; size_t nearestId(0); Double_t min_dist = std::numeric_limits<Int_t>::max(); for(size_t nid = 0; nid< current->fAllHits.size(); ++nid) { ReconHit* candidateHit = current->fAllHits[nid]; if(!candidateHit->fIsVisited && candidateHit->fLocalId != previousId && !candidateHit->fIsLeaf) { TVector3 vecPosition = current->fmppcLoc - candidateHit->fmppcLoc; Double_t dist = vecPosition.X()*vecPosition.X() + vecPosition.Y()*vecPosition.Y() + vecPosition.Z()*vecPosition.Z(); if(dist < min_dist) { min_dist = dist; nearestId = nid; } } } next = current->fAllHits[nearestId]; nextFound = (min_dist!=std::numeric_limits<Int_t>::max()); return nextFound; } void FgdReconTemplate::LoadTemplates() { // ============================== // 1. Single leaf templates // ============================== // Leaf // --- --- --- // --- -C- -X- // --- --- --- TVector3 leaf1_1(0,0,-1); FgdReconTemplate::HitTemplate leaf1_1_temp; leaf1_1_temp.hitVectors.emplace_back(leaf1_1); fLeafVectors.push_back(leaf1_1_temp); // Leaf // --- --- -X- // --- -C- --- // --- --- --- TVector3 leaf1_2(0,-1,-1); FgdReconTemplate::HitTemplate leaf1_2_temp; leaf1_2_temp.hitVectors.emplace_back(leaf1_2); fLeafVectors.push_back(leaf1_2_temp); // Leaf // --- --- --X // --- -C- --- // --- --- --- TVector3 leaf1_3(1,-1,-1); FgdReconTemplate::HitTemplate leaf1_3_temp; leaf1_3_temp.hitVectors.emplace_back(leaf1_3); fLeafVectors.push_back(leaf1_3_temp); // ============================== // 2. Two hits leaf templates // ============================== // Leaf // --- --- -X- // --- -C- -X- // --- --- --- TVector3 leaf2_1_1(0,-1,-1); TVector3 leaf2_1_2(0,0,-1); FgdReconTemplate::HitTemplate leaf2_1_temp; leaf2_1_temp.hitVectors.emplace_back(leaf2_1_1); leaf2_1_temp.hitVectors.emplace_back(leaf2_1_2); fLeafVectors.push_back(leaf2_1_temp); // Leaf // --- --- --X // --- -C- -X- // --- --- --- TVector3 leaf2_2_1(1,-1,-1); TVector3 leaf2_2_2(0,0,-1); FgdReconTemplate::HitTemplate leaf2_2_temp; leaf2_2_temp.hitVectors.emplace_back(leaf2_2_1); leaf2_2_temp.hitVectors.emplace_back(leaf2_2_2); fLeafVectors.push_back(leaf2_2_temp); // Leaf // --- --- X-- // --- -C- X-- // --- --- --- TVector3 leaf2_3_1(-1,-1,-1); TVector3 leaf2_3_2(-1,0,-1); FgdReconTemplate::HitTemplate leaf2_3_temp; leaf2_3_temp.hitVectors.emplace_back(leaf2_3_1); leaf2_3_temp.hitVectors.emplace_back(leaf2_3_2); fLeafVectors.push_back(leaf2_3_temp); // Leaf // --- --- --X // --- -C- --X // --- --- --- TVector3 leaf2_4_1(1,-1,-1); TVector3 leaf2_4_2(1,0,-1); FgdReconTemplate::HitTemplate leaf2_4_temp; leaf2_4_temp.hitVectors.emplace_back(leaf2_4_1); leaf2_4_temp.hitVectors.emplace_back(leaf2_4_2); fLeafVectors.push_back(leaf2_4_temp); // ============================== // 3. Three hits leaf templates // ============================== // Leaf // --- --- -XX // --- -C- -X- // --- --- --- TVector3 leaf3_1_1(0,-1,-1); TVector3 leaf3_1_2(1,-1,-1); TVector3 leaf3_1_3(0,0,-1); FgdReconTemplate::HitTemplate leaf3_1_temp; leaf3_1_temp.hitVectors.emplace_back(leaf3_1_1); leaf3_1_temp.hitVectors.emplace_back(leaf3_1_2); leaf3_1_temp.hitVectors.emplace_back(leaf3_1_3); fLeafVectors.push_back(leaf3_1_temp); // Leaf // --- --- XX- // --- -C- -X- // --- --- --- TVector3 leaf3_2_1(-1,-1,-1); TVector3 leaf3_2_2(0,-1,-1); TVector3 leaf3_2_3(0,0,-1); FgdReconTemplate::HitTemplate leaf3_2_temp; leaf3_2_temp.hitVectors.emplace_back(leaf3_2_1); leaf3_2_temp.hitVectors.emplace_back(leaf3_2_2); leaf3_2_temp.hitVectors.emplace_back(leaf3_2_3); fLeafVectors.push_back(leaf3_2_temp); LOG(debug) << " Leaf templates found " << fLeafVectors.size(); } void FgdReconTemplate::GetHitVectors(ReconHit* hit , std::vector<TVector3>& vecs) { for(size_t i=0; i< hit->fAllHits.size(); ++i) { ReconHit& neightbourHit = *hit->fAllHits[i]; TVector3 result = hit->fmppcLoc - neightbourHit.fmppcLoc; vecs.emplace_back(result); } } // Compares if the two vectors are equal // This also includes rotational symmetry // Make a copy of the template since it will be modified Bool_t FgdReconTemplate::AreVectorsEqual(const std::vector<TVector3>& tempVecs, const std::vector<TVector3>& vecs, Int_t& foundPermutation ) { Bool_t areEqual(false); if(tempVecs.size()!=vecs.size()) { return areEqual; } std::vector<TVector3> tempVecPermut = tempVecs; Int_t permutation(0); Int_t limitPermutations = PERMUTATIONS; while(!areEqual && permutation<=limitPermutations) { for(size_t i=0; i<tempVecs.size(); ++i) { TVector3 tmp = GetPermutation(tempVecs[i],permutation); tempVecPermut[i].SetX(tmp.X()); tempVecPermut[i].SetY(tmp.Y()); tempVecPermut[i].SetZ(tmp.Z()); } Bool_t allVecsAreEqual(true); for(size_t i=0; allVecsAreEqual && i<vecs.size(); ++i) { allVecsAreEqual = std::find(tempVecPermut.begin(), tempVecPermut.end(), vecs[i]) != tempVecPermut.end(); } areEqual = allVecsAreEqual; if(areEqual) { foundPermutation = permutation; break; } ++permutation; } return areEqual; } TVector3 FgdReconTemplate::GetPermutation(TVector3 vec, Int_t numPermutation) { Double_t rot90deg = TMath::Pi()/2; Double_t rot180deg = TMath::Pi(); if(numPermutation<0 || numPermutation>PERMUTATIONS) { throw "Invalid permutation"; } switch(numPermutation) { case 0: // No rotation break; case 1: vec.RotateZ(rot90deg); break; case 2: vec.RotateZ(2*rot90deg); break; case 3: vec.RotateZ(3*rot90deg); break; case 4: vec.RotateY(rot90deg); break; case 5: vec.RotateY(rot90deg); vec.RotateX(rot90deg); break; case 6: vec.RotateY(rot90deg); vec.RotateX(2*rot90deg); break; case 7: vec.RotateY(rot90deg); vec.RotateX(3*rot90deg); break; case 8: vec.RotateY(2*rot90deg); break; case 9: vec.RotateY(2*rot90deg); vec.RotateZ(rot90deg); break; case 10: vec.RotateY(2*rot90deg); vec.RotateZ(2*rot90deg); break; case 11: vec.RotateY(2*rot90deg); vec.RotateZ(3*rot90deg); break; case 12: vec.RotateY(3*rot90deg); break; case 13: vec.RotateY(3*rot90deg); vec.RotateX(rot90deg); break; case 14: vec.RotateY(3*rot90deg); vec.RotateX(2*rot90deg); break; case 15: vec.RotateY(3*rot90deg); vec.RotateX(3*rot90deg); break; case 16: vec.RotateX(rot90deg); break; case 17: vec.RotateX(rot90deg); vec.RotateY(rot90deg); break; case 18: vec.RotateX(rot90deg); vec.RotateY(2*rot90deg); break; case 19: vec.RotateX(rot90deg); vec.RotateY(3*rot90deg); break; case 20: vec.RotateX(-rot90deg); break; case 21: vec.RotateX(-rot90deg); vec.RotateY(rot90deg); break; case 22: vec.RotateX(-rot90deg); vec.RotateY(2*rot90deg); break; case 23: vec.RotateX(-rot90deg); vec.RotateY(3*rot90deg); break; default: break; } Double_t&& x = std::round(vec.X()); Double_t&& y = std::round(vec.Y()); Double_t&& z = std::round(vec.Z()); return TVector3(x,y,z); } } //superfgd } //reconstruction } //esbroot
[ "rigel0586@gmail.com" ]
rigel0586@gmail.com
0adc0d7186a27db30317fa44d9917cae4f72a9ab
e2ba5670f187aff6561a81601b63b4876664fc82
/game/Game/src/Gameplay/Laser/CannonLaser.cpp
feae07c4a425663881cddc2762274d3956ce4c6a
[]
no_license
AmazingCow-Game/CosmicIntruders
9a61e4103e2b156a438762c9ded18e0b64bbdf2b
de6a8805158a79c5b04ff772f566551e1a53511c
refs/heads/master
2021-09-07T08:14:52.534334
2018-02-20T02:13:47
2018-02-20T02:13:47
111,156,030
0
0
null
null
null
null
UTF-8
C++
false
false
4,759
cpp
//~---------------------------------------------------------------------------// // _______ _______ _______ _ _ // // | _ || || || | _ | | // // | |_| || || _ || || || | // // | || || | | || | // // | || _|| |_| || | // // | _ || |_ | || _ | // // |__| |__||_______||_______||__| |__| // // www.amazingcow.com // // File : CannonLaser.cpp // // Project : Cosmic Intruders // // Date : Nov 17, 2017 // // License : GPLv3 // // Author : n2omatt <n2omatt@amazingcow.com> // // Copyright : AmazingCow - 2017 // // // // Description : // // // //---------------------------------------------------------------------------~// // Header #include "Game/include/GamePlay/Laser/CannonLaser.h" // CosmicIntruders #include "Game/include/Helpers/GameUtils.h" // Usings using namespace CosmicIntruders; //----------------------------------------------------------------------------// // Constants // //----------------------------------------------------------------------------// //------------------------------------------------------------------------------ // Timer Durations. constexpr float kDuration_Explosion = 0.25f; //------------------------------------------------------------------------------ // Atlas Names - We use that to retrieve the info in the TextureAtlas. constexpr auto kAtlasName_Alive = "CannonLaser_Alive"; constexpr auto kAtlasName_Explode = "CannonLaser_Explode"; //------------------------------------------------------------------------------ // Speed constexpr auto kSpeed_Base = Cooper::Vec2(0, -700); //----------------------------------------------------------------------------// // CTOR / DTOR // //----------------------------------------------------------------------------// CannonLaser::CannonLaser() : // Base. ILaser( true, kDuration_Explosion, kSpeed_Base, GameUtils::MoveBoundsLaser() ) { Init(); } //----------------------------------------------------------------------------// // Control Functions // //----------------------------------------------------------------------------// void CannonLaser::Reset() { ILaser::Reset(); m_pTexture->RenderRect(m_aliveRect); } void CannonLaser::Explode() { ILaser::Explode(); m_pTexture->RenderRect(m_explodingRect); } //----------------------------------------------------------------------------// // Update / Render // //----------------------------------------------------------------------------// void CannonLaser::Render() { if(!Dead()) m_pTexture->Render(); } //----------------------------------------------------------------------------// // Init Functions // //----------------------------------------------------------------------------// void CannonLaser::Init() { auto p_atlas = Cooper::RES::GetAtlas(GameUtils::GameAtlasPath()); //-------------------------------------------------------------------------- // Get the texture with the alive render rect since it'll be default. // But we need to set the alive rect as well since we only load // one time but possible use them a lot. m_pTexture = p_atlas->Texture(kAtlasName_Alive); m_aliveRect = m_pTexture->RenderRect(); //-------------------------------------------------------------------------- // Load the exploding info too. m_explodingRect = p_atlas->Rectangle(kAtlasName_Explode); //-------------------------------------------------------------------------- // Setup hierarchy. m_pTexture->Parent(this); Size(m_pTexture->Size()); }
[ "n2omatt@amazingcow.com" ]
n2omatt@amazingcow.com
6381dbf9881ac8e098ba754c30d8cf311996bd51
600df3590cce1fe49b9a96e9ca5b5242884a2a70
/components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client_unittest.cc
4c6f3395a94b8ed6db34a6859eec46c07cb6b3bb
[ "BSD-3-Clause" ]
permissive
metux/chromium-suckless
efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a
72a05af97787001756bae2511b7985e61498c965
refs/heads/orig
2022-12-04T23:53:58.681218
2017-04-30T10:59:06
2017-04-30T23:35:58
89,884,931
5
3
BSD-3-Clause
2022-11-23T20:52:53
2017-05-01T00:09:08
null
UTF-8
C++
false
false
15,788
cc
// Copyright 2016 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. #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pingback_client.h" #include <memory> #include <string> #include "base/command_line.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/optional.h" #include "base/test/histogram_tester.h" #include "base/time/time.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_page_load_timing.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.h" #include "components/data_reduction_proxy/proto/client_config.pb.h" #include "components/data_reduction_proxy/proto/pageload_metrics.pb.h" #include "net/base/net_errors.h" #include "net/nqe/effective_connection_type.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" namespace data_reduction_proxy { namespace { static const char kHistogramSucceeded[] = "DataReductionProxy.Pingback.Succeeded"; static const char kHistogramAttempted[] = "DataReductionProxy.Pingback.Attempted"; static const char kSessionKey[] = "fake-session"; static const char kFakeURL[] = "http://www.google.com/"; } // namespace // Controls whether a pingback is sent or not. class TestDataReductionProxyPingbackClient : public DataReductionProxyPingbackClient { public: TestDataReductionProxyPingbackClient( net::URLRequestContextGetter* url_request_context_getter) : DataReductionProxyPingbackClient(url_request_context_getter), should_override_random_(false), override_value_(0.0f), current_time_(base::Time::Now()) {} // Overrides the bahvior of the random float generator in // DataReductionProxyPingbackClient. // If |should_override_random| is true, the typically random value that is // compared with reporting fraction will deterministically be // |override_value|. void OverrideRandom(bool should_override_random, float override_value) { should_override_random_ = should_override_random; override_value_ = override_value; } // Sets the time used for the metrics reporting time. void set_current_time(base::Time current_time) { current_time_ = current_time; } private: float GenerateRandomFloat() const override { if (should_override_random_) return override_value_; return DataReductionProxyPingbackClient::GenerateRandomFloat(); } base::Time CurrentTime() const override { return current_time_; } bool should_override_random_; float override_value_; base::Time current_time_; }; class DataReductionProxyPingbackClientTest : public testing::Test { public: DataReductionProxyPingbackClientTest() : timing_( base::Time::FromJsTime(1500) /* navigation_start */, base::Optional<base::TimeDelta>( base::TimeDelta::FromMilliseconds(1600)) /* response_start */, base::Optional<base::TimeDelta>( base::TimeDelta::FromMilliseconds(1700)) /* load_event_start */, base::Optional<base::TimeDelta>(base::TimeDelta::FromMilliseconds( 1800)) /* first_image_paint */, base::Optional<base::TimeDelta>(base::TimeDelta::FromMilliseconds( 1900)) /* first_contentful_paint */, base::Optional<base::TimeDelta>(base::TimeDelta::FromMilliseconds( 2000)) /* experimental_first_meaningful_paint */, base::Optional<base::TimeDelta>(base::TimeDelta::FromMilliseconds( 100)) /* parse_blocked_on_script_load_duration */, base::Optional<base::TimeDelta>( base::TimeDelta::FromMilliseconds(2000)) /* parse_stop */) {} TestDataReductionProxyPingbackClient* pingback_client() const { return pingback_client_.get(); } void Init() { request_context_getter_ = new net::TestURLRequestContextGetter(message_loop_.task_runner()); pingback_client_ = base::WrapUnique<TestDataReductionProxyPingbackClient>( new TestDataReductionProxyPingbackClient( request_context_getter_.get())); } void CreateAndSendPingback() { DataReductionProxyData request_data; request_data.set_session_key(kSessionKey); request_data.set_request_url(GURL(kFakeURL)); request_data.set_effective_connection_type( net::EFFECTIVE_CONNECTION_TYPE_OFFLINE); factory()->set_remove_fetcher_on_delete(true); pingback_client()->SendPingback(request_data, timing_); } net::TestURLFetcherFactory* factory() { return &factory_; } const DataReductionProxyPageLoadTiming& timing() { return timing_; } const base::HistogramTester& histogram_tester() { return histogram_tester_; } private: base::MessageLoopForIO message_loop_; scoped_refptr<net::URLRequestContextGetter> request_context_getter_; std::unique_ptr<TestDataReductionProxyPingbackClient> pingback_client_; net::TestURLFetcherFactory factory_; DataReductionProxyPageLoadTiming timing_; base::HistogramTester histogram_tester_; }; TEST_F(DataReductionProxyPingbackClientTest, VerifyPingbackContent) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); pingback_client()->OverrideRandom(true, 0.5f); pingback_client()->SetPingbackReportingFraction(1.0f); base::Time current_time = base::Time::UnixEpoch(); pingback_client()->set_current_time(current_time); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1); net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0); EXPECT_EQ(test_fetcher->upload_content_type(), "application/x-protobuf"); RecordPageloadMetricsRequest batched_request; batched_request.ParseFromString(test_fetcher->upload_data()); EXPECT_EQ(batched_request.pageloads_size(), 1); EXPECT_EQ(current_time, protobuf_parser::TimestampToTime( batched_request.metrics_sent_time())); PageloadMetrics pageload_metrics = batched_request.pageloads(0); EXPECT_EQ( timing().navigation_start, protobuf_parser::TimestampToTime(pageload_metrics.first_request_time())); EXPECT_EQ(timing().response_start.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_byte())); EXPECT_EQ( timing().load_event_start.value(), protobuf_parser::DurationToTimeDelta(pageload_metrics.page_load_time())); EXPECT_EQ(timing().first_image_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_image_paint())); EXPECT_EQ(timing().first_contentful_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_contentful_paint())); EXPECT_EQ( timing().experimental_first_meaningful_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.experimental_time_to_first_meaningful_paint())); EXPECT_EQ(timing().parse_blocked_on_script_load_duration.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.parse_blocked_on_script_load_duration())); EXPECT_EQ(timing().parse_stop.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.parse_stop())); EXPECT_EQ(kSessionKey, pageload_metrics.session_key()); EXPECT_EQ(kFakeURL, pageload_metrics.first_request_url()); EXPECT_EQ( PageloadMetrics_EffectiveConnectionType_EFFECTIVE_CONNECTION_TYPE_OFFLINE, pageload_metrics.effective_connection_type()); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1); EXPECT_FALSE(factory()->GetFetcherByID(0)); } TEST_F(DataReductionProxyPingbackClientTest, VerifyTwoPingbacksBatchedContent) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); pingback_client()->OverrideRandom(true, 0.5f); pingback_client()->SetPingbackReportingFraction(1.0f); base::Time current_time = base::Time::UnixEpoch(); pingback_client()->set_current_time(current_time); // First pingback CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1); // Two more pingbacks batched together. CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 2); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 3); // Ignore the first pingback. net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1); // Check the state of the second pingback. test_fetcher = factory()->GetFetcherByID(0); EXPECT_EQ(test_fetcher->upload_content_type(), "application/x-protobuf"); RecordPageloadMetricsRequest batched_request; batched_request.ParseFromString(test_fetcher->upload_data()); EXPECT_EQ(batched_request.pageloads_size(), 2); EXPECT_EQ(current_time, protobuf_parser::TimestampToTime( batched_request.metrics_sent_time())); // Verify the content of both pingbacks. for (size_t i = 0; i < 2; ++i) { PageloadMetrics pageload_metrics = batched_request.pageloads(i); EXPECT_EQ(timing().navigation_start, protobuf_parser::TimestampToTime( pageload_metrics.first_request_time())); EXPECT_EQ(timing().response_start.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_byte())); EXPECT_EQ(timing().load_event_start.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.page_load_time())); EXPECT_EQ(timing().first_image_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_image_paint())); EXPECT_EQ(timing().first_contentful_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.time_to_first_contentful_paint())); EXPECT_EQ( timing().experimental_first_meaningful_paint.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.experimental_time_to_first_meaningful_paint())); EXPECT_EQ(timing().parse_blocked_on_script_load_duration.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.parse_blocked_on_script_load_duration())); EXPECT_EQ(timing().parse_stop.value(), protobuf_parser::DurationToTimeDelta( pageload_metrics.parse_stop())); EXPECT_EQ(kSessionKey, pageload_metrics.session_key()); EXPECT_EQ(kFakeURL, pageload_metrics.first_request_url()); EXPECT_EQ( PageloadMetrics_EffectiveConnectionType_EFFECTIVE_CONNECTION_TYPE_OFFLINE, pageload_metrics.effective_connection_type()); } test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 2); EXPECT_FALSE(factory()->GetFetcherByID(0)); } TEST_F(DataReductionProxyPingbackClientTest, SendTwoPingbacks) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); pingback_client()->OverrideRandom(true, 0.5f); pingback_client()->SetPingbackReportingFraction(1.0f); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 2); net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1); EXPECT_TRUE(factory()->GetFetcherByID(0)); test_fetcher = factory()->GetFetcherByID(0); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 2); EXPECT_FALSE(factory()->GetFetcherByID(0)); histogram_tester().ExpectTotalCount(kHistogramAttempted, 2); } TEST_F(DataReductionProxyPingbackClientTest, NoPingbackSent) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); pingback_client()->OverrideRandom(true, 0.5f); pingback_client()->SetPingbackReportingFraction(0.0f); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, false, 1); histogram_tester().ExpectTotalCount(kHistogramSucceeded, 0); EXPECT_FALSE(factory()->GetFetcherByID(0)); } TEST_F(DataReductionProxyPingbackClientTest, VerifyReportingBehvaior) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); // Verify that if the random number is less than the reporting fraction, the // pingback is created. pingback_client()->SetPingbackReportingFraction(0.5f); pingback_client()->OverrideRandom(true, 0.4f); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1); net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0); EXPECT_TRUE(test_fetcher); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 1); // Verify that if the random number is greater than the reporting fraction, // the pingback is not created. pingback_client()->OverrideRandom(true, 0.6f); CreateAndSendPingback(); histogram_tester().ExpectBucketCount(kHistogramAttempted, false, 1); test_fetcher = factory()->GetFetcherByID(0); EXPECT_FALSE(test_fetcher); // Verify that if the random number is equal to the reporting fraction, the // pingback is not created. Specifically, if the reporting fraction is zero, // and the random number is zero, no pingback is sent. pingback_client()->SetPingbackReportingFraction(0.0f); pingback_client()->OverrideRandom(true, 0.0f); CreateAndSendPingback(); histogram_tester().ExpectBucketCount(kHistogramAttempted, false, 2); test_fetcher = factory()->GetFetcherByID(0); EXPECT_FALSE(test_fetcher); // Verify that the command line flag forces a pingback. base::CommandLine::ForCurrentProcess()->AppendSwitch( data_reduction_proxy::switches::kEnableDataReductionProxyForcePingback); pingback_client()->SetPingbackReportingFraction(0.0f); pingback_client()->OverrideRandom(true, 1.0f); CreateAndSendPingback(); histogram_tester().ExpectBucketCount(kHistogramAttempted, true, 2); test_fetcher = factory()->GetFetcherByID(0); EXPECT_TRUE(test_fetcher); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, true, 2); } TEST_F(DataReductionProxyPingbackClientTest, FailedPingback) { Init(); EXPECT_FALSE(factory()->GetFetcherByID(0)); pingback_client()->OverrideRandom(true, 0.5f); pingback_client()->SetPingbackReportingFraction(1.0f); CreateAndSendPingback(); histogram_tester().ExpectUniqueSample(kHistogramAttempted, true, 1); net::TestURLFetcher* test_fetcher = factory()->GetFetcherByID(0); EXPECT_TRUE(test_fetcher); // Simulate a network error. test_fetcher->set_status(net::URLRequestStatus( net::URLRequestStatus::FAILED, net::ERR_INVALID_AUTH_CREDENTIALS)); test_fetcher->delegate()->OnURLFetchComplete(test_fetcher); histogram_tester().ExpectUniqueSample(kHistogramSucceeded, false, 1); } } // namespace data_reduction_proxy
[ "enrico.weigelt@gr13.net" ]
enrico.weigelt@gr13.net
fbad5b6c125c9ca4d549db67826891e3cd859a9e
603b96b852375b0639afb1cf29caa11ae6d8785f
/RenderLayer.h
b7a3502dcefff943c2116b56582f7544ec896900
[]
no_license
Coder5560/disappear
6666bf4f4b712f41abad52d2142e43822296a4e8
cfee9c5d5aec7c2e9780310bf24eedaa79c22ca1
refs/heads/master
2021-03-12T23:40:33.706668
2015-08-28T14:13:56
2015-08-28T14:13:56
41,550,889
0
0
null
null
null
null
UTF-8
C++
false
false
416
h
#pragma once #include "cocos2d.h" USING_NS_CC; class RenderLayer { public: RenderLayer(); ~RenderLayer(); static RenderLayer* getInstance(); Node* createHudNode(); Node* createGameNode(); Node* createBackgroundNode(); Layer* getBackgroundLayer(); Layer* getGameLayer(); Layer* getHudLayer(); void resetAll(); private : Size winSize; Layer* gameLayer; Layer* hudLayer; Layer* backgroundLayer; };
[ "Coder5560@gmail.com" ]
Coder5560@gmail.com
d42233c9102d55ed94b9641e67daed473cdbf90b
bb609ad7b827ef4e8647af20aa9db0348acc0a43
/EASY/Pallindrome/Solution1.cpp
e2c86d850a31d2985a3a683ac9aa0401be2fd6ca
[]
no_license
silvistershebin/Algos
1c71396ce14ed995876ed674b9c82c0c073e0e37
4b9caffebdd8547106f736f70668ce24ab066a8d
refs/heads/master
2022-11-20T16:57:50.379554
2020-07-24T04:10:25
2020-07-24T04:10:25
269,698,949
0
0
null
null
null
null
UTF-8
C++
false
false
407
cpp
/**************************************************** TC: O(n^2) : string concat takes n time SC: O(n) Method: Check if given string is equal to the reversed string *****************************************************/ using namespace std; bool isPalindrome(string str) { string reverse = ""; int len = str.length() - 1; while(len >= 0) { reverse += str[len]; len--; } return str == reverse; }
[ "silvistershebin@gmail.com" ]
silvistershebin@gmail.com
dd6a55ae5167ef1c2c6392eff41ba6107a720496
7042d59562ebd69c7cfa982d9eeccb24fb10fa68
/Materias Obrigatorias/2º Semestre/MVGA - Matrizes, Vetores e Geometria Analítica/Helton/EPS/Ep Desconhecido 2009/ep_etc/of/ofPolygonBoundaries.h
5edaff6e7be0eb47f5e2615b54ee126537a3d691
[]
no_license
ThallesRg/drivesi
fa79f894ae1ddbb563283fee9885e0b24e5c49d8
cd8462815949cb9fd4aa775138f48a4b7f8b0f04
refs/heads/master
2023-04-30T08:00:36.731137
2021-05-28T05:29:45
2021-05-28T05:29:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,026
h
#ifndef OFPOLYGONBOUNDARIES_H #define OFPOLYGONBOUNDARIES_H #include "ofList.h" #define SVERTEX15 typename ofPolygonBoundaries<size,_Traits>::sVertex #define SPACE typename ofPolygonBoundaries<size,_Traits>::space template <int size, class _Traits> class ofPolygonBoundaries { public: typedef typename _Traits::space space; typedef typename _Traits::sVertex sVertex; ofPolygonBoundaries(); ~ofPolygonBoundaries(); int addBoundary(int numberOfPoints, space **coords); void addOnBoundary(int boundary, int position, space *coords); int getNumberOfBoundaries(); int getNumberOfPoints(int boundary); void setVertex(int boundary, int pos, sVertex *v); sVertex *getVertex(int boundary, int pos); space getCoord(int boundary, int pos, int coord); typedef struct { sVertex *v; space coords[size]; } node; typedef struct { of::ofList<node*> points; } bound; of::ofList<bound*> bounds; }; template <int size, class _Traits> ofPolygonBoundaries<size,_Traits>::ofPolygonBoundaries() { } template <int size, class _Traits> ofPolygonBoundaries<size,_Traits>::~ofPolygonBoundaries() { for(int i = 0; i < bounds.getSize(); i++) for(int j = 0; j < bounds.getPos(i)->points.getSize(); j++) delete bounds.getPos(i)->points.getPos(j); } template <int size, class _Traits> int ofPolygonBoundaries<size,_Traits>::addBoundary(int numberOfPoints, space **coords ) { int i; node *n; bound *b = new bound; for(i = 0; i < numberOfPoints; i++) { n = new node; n->v = NULL; n->coords[0] = coords[i][0]; n->coords[1] = coords[i][1]; b->points.insert(n); } bounds.insert(b); return (bounds.getSize()-1); } template <int size, class _Traits> void ofPolygonBoundaries<size,_Traits>::setVertex(int boundary, int pos, sVertex *v) { bounds.getPos(boundary)->points.getPos(pos)->v = v; //v->f = boundary + 1.0; } template <int size, class _Traits> SVERTEX15 *ofPolygonBoundaries<size,_Traits>::getVertex(int boundary, int pos) { return bounds.getPos(boundary)->points.getPos(pos)->v; } template <int size, class _Traits> SPACE ofPolygonBoundaries<size,_Traits>::getCoord(int boundary, int pos, int coord) { return bounds.getPos(boundary)->points.getPos(pos)->coords[coord]; } template <int size, class _Traits> int ofPolygonBoundaries<size,_Traits>::getNumberOfBoundaries() { return bounds.getSize(); } template <int size, class _Traits> int ofPolygonBoundaries<size,_Traits>::getNumberOfPoints(int boundary) { return bounds.getPos(boundary)->points.getSize(); } template <int size, class _Traits> void ofPolygonBoundaries<size,_Traits>::addOnBoundary(int boundary, int position, space *coords) { node *n = new node; n->v = NULL; n->coords[0] = coords[0]; n->coords[1] = coords[1]; bounds.getPos(boundary)->points.insert(n,position); } #undef SVERTEX15 #undef SPACE #endif
[ "driveeach@gmail.com" ]
driveeach@gmail.com
d6cf88f086a220cb9242b915d21765b3fe8e33cd
9f61ba4f82fff06c3970951f64970cd85325e220
/src/HTML/html.h
e7e63292d78a00e68b0322f000cc1ae68f29fd83
[ "MIT" ]
permissive
dorin131/DorinBrowser-experiment
fe926dcc9df51f4463096061d53a3e7cac8d14db
e3c92e261a8b68586451e82ef0a1fb2c7fa80706
refs/heads/master
2022-11-10T16:45:27.903596
2020-06-29T19:14:50
2020-06-29T19:14:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
206
h
#ifndef HTML_H #define HTML_H #include <iostream> namespace html { class HTML { public: HTML(); std::string parse(std::string); // should return an AST }; } // namespace html #endif // HTML_H
[ "dorin.fodor@gmail.com" ]
dorin.fodor@gmail.com
2e256122f5c35964fb93e31ba659b003a0bc5ba2
e4355967555857fd536787dce39ca30426ffa702
/867/Game Platform/工具/SolutionAndroid/PukNine/ServerConfig.cpp
f25c5a7abdc4927471f78d12836cd6322d9d8a74
[]
no_license
herox25000/oathx-ogrex-editor
f0fd6044f8065db9cb50a80376e52f502734e877
f645c7997f27e11a9063a0d352accd98a474cef1
refs/heads/master
2020-12-24T14:35:34.912603
2013-08-24T06:20:06
2013-08-24T06:20:06
32,935,652
6
9
null
null
null
null
GB18030
C++
false
false
4,868
cpp
// ServerConfig.cpp : 实现文件 // #include "stdafx.h" #include "SmallNine.h" #include "ServerConfig.h" #include ".\serverconfig.h" // CServerConfig 对话框 IMPLEMENT_DYNAMIC(CServerConfig, CDialog) CServerConfig::CServerConfig(CWnd* pParent /*=NULL*/) : CDialog(CServerConfig::IDD, pParent) { } CServerConfig::~CServerConfig() { } void CServerConfig::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CServerConfig, CDialog) ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1) ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2) ON_BN_CLICKED(IDC_RADIO3, OnBnClickedRadio3) ON_BN_CLICKED(IDC_RADIO4, OnBnClickedRadio4) ON_BN_CLICKED(IDC_RADIO5, OnBnClickedRadio5) ON_BN_CLICKED(IDC_RADIO6, OnBnClickedRadio6) ON_BN_CLICKED(IDC_RADIO7, OnBnClickedRadio7) ON_BN_CLICKED(IDC_RADIO8, OnBnClickedRadio8) ON_BN_CLICKED(IDC_RADIO9, OnBnClickedRadio9) ON_BN_CLICKED(IDOK, OnBnClickedOk) END_MESSAGE_MAP() BOOL CServerConfig::OnInitDialog() { CDialog::OnInitDialog(); LoadServerConfig(); return TRUE; } void CServerConfig::LoadServerConfig() { UINT nWinControl = GetPrivateProfileInt("Option", "OpenControl", 0, ".\\PaiJiu.ini"); switch(nWinControl) { case 0: ((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE); break; case 1: ((CButton*)GetDlgItem(IDC_RADIO2))->SetCheck(TRUE); break; case 2: ((CButton*)GetDlgItem(IDC_RADIO3))->SetCheck(TRUE); break; case 3: ((CButton*)GetDlgItem(IDC_RADIO4))->SetCheck(TRUE); break; case 4: ((CButton*)GetDlgItem(IDC_RADIO5))->SetCheck(TRUE); break; case 5: ((CButton*)GetDlgItem(IDC_RADIO6))->SetCheck(TRUE); break; case 6: ((CButton*)GetDlgItem(IDC_RADIO7))->SetCheck(TRUE); break; case 7: ((CButton*)GetDlgItem(IDC_RADIO8))->SetCheck(TRUE); break; case 8: ((CButton*)GetDlgItem(IDC_RADIO9))->SetCheck(TRUE); break; default: break; } UINT nWinRate = GetPrivateProfileInt("Option", "WinRate", 5, ".\\PaiJiu.ini"); UINT nMaxLose = GetPrivateProfileInt("Option", "MaxLose", 100000000, ".\\PaiJiu.ini"); UINT nPlayerMaxWin = GetPrivateProfileInt("Option", "PlayMaxWin", 100000000, ".\\PaiJiu.ini"); char szText[MAX_PATH]; sprintf(szText, "%d", nWinRate); SetDlgItemText(IDC_EDIT1, szText); sprintf(szText, "%d", nMaxLose); SetDlgItemText(IDC_EDIT2, szText); sprintf(szText, "%d", nPlayerMaxWin); SetDlgItemText(IDC_EDIT3, szText); } // CServerConfig 消息处理程序 void CServerConfig::OnBnClickedRadio1() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "0", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio2() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "1", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio3() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "2", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio4() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "3", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio5() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "4", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio6() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "5", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio7() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "6", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio8() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "7", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedRadio9() { bool bRet = WritePrivateProfileString("Option", "OpenControl", "8", ".\\PaiJiu.ini"); if (!bRet) { MessageBox("找不到配置文件", NULL, MB_OK); } } void CServerConfig::OnBnClickedOk() { CString buffer; GetDlgItemText(IDC_EDIT1, buffer); WritePrivateProfileString("Option", "WinRate", buffer.GetBuffer(), ".\\PaiJiu.ini"); GetDlgItemText(IDC_EDIT2, buffer); WritePrivateProfileString("Option", "MaxLose", buffer.GetBuffer(), ".\\PaiJiu.ini"); GetDlgItemText(IDC_EDIT3, buffer); WritePrivateProfileString("Option", "PlayMaxWin", buffer.GetBuffer(), ".\\PaiJiu.ini"); OnOK(); }
[ "ilovejiaqi520@gmail.com@a113e17c-5e0c-ebba-c532-3ad10810a225" ]
ilovejiaqi520@gmail.com@a113e17c-5e0c-ebba-c532-3ad10810a225
1245e32adc94928c29ee0d41bc1cda3142816731
a8830149d4f2b0d55fe44bd655362293e2e44e6b
/Alt/AndroduinoBluetooth.h
beaade843472d9cbf8d926b5e7f96e14358c3886
[]
no_license
einspunktnull/einspunktnull-lib-arduino
2b289e0dc5c5eb0c8cab92885fb6d56046c615c1
6c4047e501842cac565b573bb5e49c785f62fbaa
refs/heads/master
2020-04-12T10:33:35.425892
2015-04-22T12:11:20
2015-04-22T12:11:20
14,661,517
0
0
null
null
null
null
UTF-8
C++
false
false
3,146
h
/* AndroduinoBluetooth.h - Arduino Library for AndroduinoBluetooth Copyright (c) 2012 Albrecht Nitsche. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Acknowledgements: This library is based on the MeetAndroid library from Bonifaz Kaufmann's Amarino Toolkit (http://www.amarino-toolkit.net/). The original library has been modified to address the specific demand to communicate with the AndroduinoBluetooth based Software. Website: http://einspunktnull.net last modified by Albrecht Nitsche 19th July 2012 */ #ifndef Androduino_h #define Androduino_h #include <inttypes.h> #include "Print.h" /****************************************************************************** * Definitions ******************************************************************************/ class AndroduinoBluetooth: public Print { private: const static uint8_t BYTE_BUFFER_SIZE = 64; const static uint8_t BYTE_BUFFER_WAIT_TIME = 30; const static uint8_t FUNCTION_BUFFER_SIZE = 128; // 48-122 (in ascii: 0 - z) const static char BYTE_START = 0x11; //(DC1 - device control 1); const static char BYTE_BREAK = 0x12; //(DC2 - device control 2); const static char BYTE_END = 0x13; //(DC3 - device control 3); const static char BYTE_DELIM = 0x14; //(DC4 - device control 4); uint8_t _buffer[BYTE_BUFFER_SIZE]; uint8_t _count; int _numValues; void handleMessage(void); int getArrayLength(void); public: AndroduinoBluetooth(void); bool receive(void); void flush(void); void getBuffer(uint8_t[]); void registerFunction(void (*)(uint8_t, uint8_t), uint8_t); void unregisterFunction(uint8_t); typedef void (*H_voidFuncPtr)(uint8_t, uint8_t); H_voidFuncPtr _intFunc[FUNCTION_BUFFER_SIZE]; H_voidFuncPtr _errorFunc; size_t write(uint8_t); uint8_t getByte(); void getString(char[]); long getLong(); int getInt(); int getIntAt(int); void getIntValues(int[]); float getFloat(); float getFloatAt(int); void getFloatValues(float[]); double getDouble(); double getDoubleAt(int); void getDoubleValues(float[]); // in Arduino double and float are the same void send(char); void send(char, char); void send(char, const char[]); void send(char, uint8_t); void send(char, int); void send(char, unsigned int); void send(char, long); void send(char, unsigned long); void send(char, double); void sendln(void); }; // Arduino 0012 workaround #undef int #undef char #undef long #undef byte #undef float #undef abs #undef round #endif
[ "nitsche@einspunktnull.net" ]
nitsche@einspunktnull.net
b32f108dc3020bdf7cca8dabf8ddac37f4a7703c
d5f77aa02df88c71ef4f898db40434bf4c1f3010
/source/slang/slang-ir-restructure-scoping.cpp
0b8e37d310d7ee91575fb3d9a259bb0f6c2da79c
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-public-domain", "MIT" ]
permissive
Yuu-233/slang
98eca809345cbc7113d449da65fff9c6406775c5
c5a7a06f2dfb7d81f38f8c1ed447543ee6f18ce2
refs/heads/master
2023-07-06T13:30:16.239376
2021-07-29T02:56:59
2021-07-29T02:56:59
390,189,438
0
0
MIT
2021-07-29T02:56:59
2021-07-28T02:40:46
null
UTF-8
C++
false
false
14,508
cpp
// slang-ir-restructure-scoping.cpp #include "slang-ir-restructure-scoping.h" #include "slang-ir.h" #include "slang-ir-insts.h" #include "slang-ir-restructure.h" namespace Slang { /// Try to find the first structured region that represents `block` /// /// In general the same block may appear as multiple regions, /// so this will return the first region in the linked list. static SimpleRegion* getFirstRegionForBlock( RegionTree* regionTree, IRBlock* block) { SimpleRegion* region = nullptr; if( regionTree->mapBlockToRegion.TryGetValue(block, region) ) { return region; } return nullptr; } /// Try to find the first structured region that contains `inst`. static SimpleRegion* getFirstRegionForInst( RegionTree* regionTree, IRInst* inst) { auto ii = inst; while(ii) { if(auto block = as<IRBlock>(ii)) return getFirstRegionForBlock(regionTree, block); ii = ii->getParent(); } return nullptr; } /// Compute the depth of a node in the region tree. /// /// This is the number of nodes (including `region`) /// on a path from `region` to the root. /// static Int computeDepth(Region* region) { Int depth = 0; for( Region* rr = region; rr; rr = rr->getParent() ) { depth++; } return depth; } /// Get the `n`th ancestor of `region`. /// /// When `n` is zero, this returns `region`. /// When `n` is one, this returns the parent of `region`, and so forth. /// static Region* getAncestor(Region* region, Int n) { Region* rr = region; for( Int ii = 0; ii < n; ++ii ) { SLANG_ASSERT(rr); rr = rr->getParent(); } return rr; } /// Find a region that is an ancestor of both `left` and `right`. static Region* findCommonAncestorRegion( Region* left, Region* right) { // Rather than blinding search through each ancestor of `left` // and see if it is also an ancestor of `right` and vice-versa, // let's try to be smart about this. // // We will start by computing the depth of `left` and `right`: // Int leftDepth = computeDepth(left); Int rightDepth = computeDepth(right); // Whatever the common ancestor is, it can't be any deeper // than the minimum of these two depths. // Int minDepth = Math::Min(leftDepth, rightDepth); // Let's fetch the ancestor of each of `left` and `right` // corresponding to that depth: // Region* leftAncestor = getAncestor(left, leftDepth - minDepth); Region* rightAncestor = getAncestor(right, rightDepth - minDepth); // Now we know that `leftAncestor` and `rightAncestor` // must have the same depth. Let's go ahead and assert // it just to be safe: // SLANG_ASSERT(computeDepth(leftAncestor) == minDepth); SLANG_ASSERT(computeDepth(rightAncestor) == minDepth); // If `leftAncestor` and `rightAncestor` are the same node, // then we've found a common ancestor, otherwise we should // look at their parents. Because the depth must match // on both sides, we will never risk missing an ancestor. // while( leftAncestor != rightAncestor ) { leftAncestor = leftAncestor->getParent(); rightAncestor = rightAncestor->getParent(); } // Okay, we've found a common ancestor. // Region* commonAncestor = leftAncestor; return commonAncestor; } /// Find a simple region that is an ancestor of both `left` and `right`. static SimpleRegion* findSimpleCommonAncestorRegion( Region* left, Region* right) { // Start by finding a common ancestor without worrying about it being simple. Region* ancestor = findCommonAncestorRegion(left, right); // Now search for a simple region up the tree. while( ancestor ) { if(ancestor->getFlavor() == Region::Flavor::Simple) return (SimpleRegion*) ancestor; ancestor = ancestor->getParent(); } // This shouldn't ever occur. The root of the region tree should // be a simple regions that represents the entry block of the // function. // SLANG_UNEXPECTED("no common ancestor found in region tree"); UNREACHABLE_RETURN(nullptr); } IRInst* getDefaultInitVal( IRBuilder* builder, IRType* type) { switch( type->getOp() ) { default: return nullptr; case kIROp_BoolType: return builder->getBoolValue(false); case kIROp_IntType: case kIROp_UIntType: case kIROp_UInt64Type: return builder->getIntValue(type, 0); case kIROp_HalfType: case kIROp_FloatType: case kIROp_DoubleType: return builder->getFloatValue(type, 0.0); // TODO: handle vector/matrix types here, by // creating an appropriate scalar value and // then "splatting" it. } } /// Initialize a variable to a sane default value, if possible. void defaultInitializeVar( IRBuilder* builder, IRVar* var, IRType* type) { IRInst* initVal = nullptr; switch( type->getOp() ) { case kIROp_VoidType: default: // By default, see if we can synthesize an IR value // to be used as the default, and allow the logic // below to store it into the variable. initVal = getDefaultInitVal(builder, type); break; // TODO: Handle aggregate types (structures, arrays) // explicitly here, since they need to be careful about // the cases where an element/field type might not // be something we can default-initialize. } if( initVal ) { builder->emitStore(var, initVal); } } /// Detect and fix any structured scoping issues for a given `def` instruction. /// /// The `defRegion` should be the region that contains `def`, and `regionTree` /// should be the region tree for the function that contains `def`. /// static void fixValueScopingForInst( IRInst* def, SimpleRegion* defRegion, RegionTree* regionTree) { // This algorithm should not consider "phi nodes" for now, // because the emit logic will already create variables for them. // We could consider folding the logic to move out of SSA form // into this function, but that would add a lot of complexity for now. if(def->getOp() == kIROp_Param) return; // We would have a scoping violation if there exists some // use `u` of `def` such that the region containing `u` // (call it `useRegion`) is not a descendent of `defRegion` // in the region tree. // // If there are no scoping violations, we don't want to do // anything. If there *are* any scoping violations, then // we ill need to introduce a temporary `tmp`, store into // it right after `def`, and then load from it at any "bad" // use sites. // // Of course, for the whole thing to work, we also need // to put `tmp` into a block somwhere, and it needs to // be a block that is visible to all of the uses, or we // are just back int the same mess again. // // The right block to use for inserting `tmp` is the least // common ancestor of `def` and all the "bad" uses, so // we will get a bit "clever" and fold in the search for // bad uses with the computation of the region we should // insert `tmp` into (to avoid looping over the uses // twice). // SimpleRegion* insertRegion = defRegion; IRVar* tmp = nullptr; // If we end up needing to insert code we'll need an IR builder, // so we will go ahead and create one now. // // TODO: the logic to compute `module` here could be hoisted // out earlier, rather than being done per-instruction. // IRModule* module = regionTree->irCode->getModule(); SharedIRBuilder sharedBuilder; sharedBuilder.session = module->session; sharedBuilder.module = module; IRBuilder builder; builder.sharedBuilder = &sharedBuilder; // Because we will be changing some of the uses of `def` // to use other values while we iterate the list, we // need to be a bit careful and extract the next use // in the linked list *before* we operator on `u`. // IRUse* nextUse = nullptr; for( auto u = def->firstUse; u; u = nextUse ) { nextUse = u->nextUse; // Looking at the use site `u`, we'd like to check if // it violates our scoping rules. // // As a simple early-exit case, if the user is in // the same block as the definition, there are no problems. // IRInst* user = u->getUser(); if(user->getParent() == defRegion->block) continue; // Otherwise, let's find the structures control-flow // region that holds the user. We expect to always // find one, because the use site must be in the same // function. // // TODO: Double check that logic if we ever introduce // things like nested function. // SimpleRegion* useRegion = getFirstRegionForInst(regionTree, user); // If there is no region associated with the use, then // the use must be in unreachable code (part of the CFG, // but not part of the region tree). We will skip // such uses for now, since they won't even appear in // the output. // if(!useRegion) continue; // Now we want to check if `useRegion` is a child/descendent // of a region that has the same block as `defRegion`. // If it is, then there is no scoping problem with this use. // if(useRegion->isDescendentOf(defRegion->block)) continue; // If we've gotten this far, we know that `u` is a "bad" // use of `def`, and needs fixing. // // We will create the `tmp` variable on demand, so // that we create it when the first "bad" use is encountered, // and then re-use it for subsequent bad uses. // if( !tmp ) { // We will create a temporary to represent `def`, // and insert a `store` into it right after `def`. // // Note: we are inserting the new variable right // after `def` for now, just because we don't // yet know the final region that it should be // placed into. We will move it to the correct // location when we are done. // builder.setInsertBefore(def->getNextInst()); tmp = builder.emitVar(def->getDataType()); builder.emitStore(tmp, def); } // In order to know where `tmp` should be defined // at the end of the algorithm, we need to compute // a valid `insertRegion` that is an ancestor of // all of the use sites (and it also a simple region // so that we can insert into its IR block). // // We need to deal with one complexity in our restructuring // process, which is that a block may be duplicated into // one or more regions, so we loop over all the regions // for the same block as `useRegion`. // for(auto rr = useRegion; rr; rr = rr->nextSimpleRegionForSameBlock) { insertRegion = findSimpleCommonAncestorRegion( insertRegion, rr); } // To fix up the use `u`, we will need to change // it from using `def` to using a load from `tmp` // builder.setInsertBefore(user); IRInst* tmpVal = builder.emitLoad(tmp); // We are clobbering the value used by the `IRUse` `u`, // while will cut it out of the list of uses for `def`. // We need to be careful when doing this to not disrupt // our iteration of the uses of `def`, so we carefully // used the `nextUse` temporary at the start of the loop. // u->set(tmpVal); } // At the end of the loop, the `tmp` variable will have // been created if and only if we fixed up anything. // if( tmp ) { // If we created a temporary, then now we need to move // its definition to the right place, which is the // `insertRegion` that we computed during the loop. // // We'd like to insert our temporary near the top // of the region, since that is the conventional // place for local variables to go. // tmp->insertBefore( insertRegion->block->getFirstOrdinaryInst()); // The whole point of the transformation we are doing // here is that `def` is not on the "obvious" control // flow path to one or more uses (which are now using // `tmp`), but that means that it might not be "obvious" // to a downstream compiler that `tmp` always gets // initialized (by the code we inserted after `def`) // before each of these use sites. // // We *know* that things are valid as long as our // dominator tree was valid - there is no way to // get to the block that loads from `tmp` without passing // through the block that computes `def` (and then // stores it into `tmp`) first. // // To avoid warnings/errros, we will go ahead and try // to emit logic to "default initialize" the `tmp` // variable if possible. // builder.setInsertBefore(tmp->getNextInst()); defaultInitializeVar(&builder, tmp, def->getDataType()); } } void fixValueScoping(RegionTree* regionTree) { // We are going to have to walk through every instruction // in the code of the function to detect an bad cases. // auto code = regionTree->irCode; for(auto block : code->getBlocks()) { // All of the instruction in `block` will have the same // parent region, so we will look it up now rather than // have to re-do this work on a per-instruction basis. // auto parentRegion = getFirstRegionForBlock(regionTree, block); // If a block has no region then it must be unreachable, // so we will skip it entirely for this pass. // // TODO: we should be eliminating unrechable blocks anyway. // if(!parentRegion) continue; for(auto inst : block->getDecorationsAndChildren()) { fixValueScopingForInst(inst, parentRegion, regionTree); } } } }
[ "noreply@github.com" ]
noreply@github.com
a110af29f5f466c7f254e3dcb95e7fd1b569b64f
edda6e95eed07a47a3fb0fafeccd655bb176f411
/1165 - Prime Number.cpp
c0f86a7961420fc6af6f3bbde8abcdeee93c94e7
[]
no_license
diaaserag/URI-ONLINE-JUDGE-
067481bcf72afb84096f4ba943ed3fb6f6cbc7b6
70e43288e73642ed667bbdedf15a18aa219609b6
refs/heads/main
2023-07-11T04:52:24.882819
2021-08-12T12:41:12
2021-08-12T12:41:12
395,310,505
0
0
null
null
null
null
UTF-8
C++
false
false
640
cpp
// main.cpp // answer 1165 - Prime Number uri online judge // solved by diaa serag // Try hard before using other programmers' codes #include<iostream> using namespace std; int main() { int count,x,c=0; cin>>count; while(count--) { c=0; cin>>x; for(int i=2;i<x/2;i++) { if(x%i==0&&x!=i) { cout<<x<<" nao eh primo"<<"\n"; c=100; break; } } if(x==4) cout<<x<<" nao eh primo"<<"\n"; else if(c==0) cout<<x<<" eh primo"<<"\n"; } return 0; }
[ "diaaserag55@gmail.com" ]
diaaserag55@gmail.com
11fd80416b0dd0acb35648d9f32fb5a6a0796e89
751bdc3d365a64b18d78e8c2fb9f6ea00452764f
/apex/networking/email_address.h
92b9837163c8d040a59fc6c324b12a82014d532b
[]
no_license
ca2/app
b1de035566d9664aa7c5c9a94378cc352b1836ec
afdedd20df2f6dce81c63bc8a9db6de14503076e
refs/heads/main
2023-08-27T07:19:45.584624
2023-08-26T12:28:28
2023-08-26T12:28:28
98,031,531
19
7
null
2017-08-14T11:13:14
2017-07-22T12:59:27
C++
UTF-8
C++
false
false
991
h
#pragma once namespace networking { class CLASS_DECL_APEX email_address { public: string m_strName; string m_strDomain; string m_strTop; string m_strSub; email_address(); email_address(const ::scoped_string & scopedstrEmail); email_address(const email_address & addr); string get_name() const { return m_strName; } string get_domain() const { return m_strDomain; } string get_top_domain() const { return m_strTop; } string get_sub_domain() const { return m_strSub; } string to_string() const { return m_strName + "@" + m_strDomain; } void set_email_address(const ::scoped_string& scopedstrEmail); email_address & operator = (const email_address & addr); email_address& operator = (const ::scoped_string& scopedstrEmail) { return *this = (const email_address&)scopedstrEmail; } }; } // namespace net
[ "camilosasuketbs@gmail.com" ]
camilosasuketbs@gmail.com
68fdfb30c6a4a0579e2e8e72ee35f12444560a16
97b62e4093aeeaf2a3c5cc62327947df023203f0
/pkgIntrogression/src/RcppExports.cpp
6230f19b49638315d86d3ae9e041f548f7acdf2c
[ "Apache-2.0" ]
permissive
freekdh/popgen-introgression
9b3ed09b68e79490d820362ea401b5aaded51cd2
f26c7b84efee64ec5bb4e662753e052195b7fc71
refs/heads/master
2021-09-21T17:53:55.023304
2018-08-29T21:46:46
2018-08-29T21:46:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,459
cpp
// Generated by using Rcpp::compileAttributes() -> do not edit by hand // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #include <Rcpp.h> using namespace Rcpp; // RcppIntrogressionSimulation Rcpp::List RcppIntrogressionSimulation(Rcpp::List parslist, int setthreads, bool progressbar); RcppExport SEXP _pkgIntrogression_RcppIntrogressionSimulation(SEXP parslistSEXP, SEXP setthreadsSEXP, SEXP progressbarSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< Rcpp::List >::type parslist(parslistSEXP); Rcpp::traits::input_parameter< int >::type setthreads(setthreadsSEXP); Rcpp::traits::input_parameter< bool >::type progressbar(progressbarSEXP); rcpp_result_gen = Rcpp::wrap(RcppIntrogressionSimulation(parslist, setthreads, progressbar)); return rcpp_result_gen; END_RCPP } // ShinyInitializeSimulation void ShinyInitializeSimulation(const Rcpp::List& parslist); RcppExport SEXP _pkgIntrogression_ShinyInitializeSimulation(SEXP parslistSEXP) { BEGIN_RCPP Rcpp::RNGScope rcpp_rngScope_gen; Rcpp::traits::input_parameter< const Rcpp::List& >::type parslist(parslistSEXP); ShinyInitializeSimulation(parslist); return R_NilValue; END_RCPP } // ShinyRunSimulation void ShinyRunSimulation(); RcppExport SEXP _pkgIntrogression_ShinyRunSimulation() { BEGIN_RCPP Rcpp::RNGScope rcpp_rngScope_gen; ShinyRunSimulation(); return R_NilValue; END_RCPP } // ShinyWriteOutputandCleanup Rcpp::List ShinyWriteOutputandCleanup(); RcppExport SEXP _pkgIntrogression_ShinyWriteOutputandCleanup() { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; Rcpp::RNGScope rcpp_rngScope_gen; rcpp_result_gen = Rcpp::wrap(ShinyWriteOutputandCleanup()); return rcpp_result_gen; END_RCPP } static const R_CallMethodDef CallEntries[] = { {"_pkgIntrogression_RcppIntrogressionSimulation", (DL_FUNC) &_pkgIntrogression_RcppIntrogressionSimulation, 3}, {"_pkgIntrogression_ShinyInitializeSimulation", (DL_FUNC) &_pkgIntrogression_ShinyInitializeSimulation, 1}, {"_pkgIntrogression_ShinyRunSimulation", (DL_FUNC) &_pkgIntrogression_ShinyRunSimulation, 0}, {"_pkgIntrogression_ShinyWriteOutputandCleanup", (DL_FUNC) &_pkgIntrogression_ShinyWriteOutputandCleanup, 0}, {NULL, NULL, 0} }; RcppExport void R_init_pkgIntrogression(DllInfo *dll) { R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); }
[ "freek@debian.telus" ]
freek@debian.telus
dc265e4d832c1956181357b668e42afdc998df3e
d275fa50335db1641f57da56216b4320620c3ebe
/childwidgetg.cpp
d3b25c819aac30c4164c69bea03a1e2859c7b6fa
[]
no_license
zmxyt/tutorsoft
665fcb3bc3e813b9ebc8bb124b4f1157ee7f5e5f
fb52ade82293d4b3d4c19fadeab9cbda49b13eef
refs/heads/master
2020-05-22T13:50:17.624881
2019-07-03T09:30:44
2019-07-03T09:30:44
186,366,980
0
0
null
null
null
null
UTF-8
C++
false
false
4,498
cpp
#pragma execution_character_set("utf-8") #include "childwidgetg.h" #include "ui_childwidgetg.h" #include "../mainwidget.h" #include "../qxmessagebox/qxmessagebox.h" #include "../database/userdatabase.h" ChildWidgetG::ChildWidgetG(QWidget *parent) : QWidget(parent), ui(new Ui::ChildWidgetG) { ui->setupUi(this); } ChildWidgetG::~ChildWidgetG() { delete ui; } //QWidget的showEvent方法是在显示前触发的。 void ChildWidgetG::showEvent(QShowEvent *event) { QVector<QVector<QString>> allinfo = queryAll("teacher_information"); for(int i =0;i < allinfo.size();i++){ //currentuser当前用户;Widget部件 if(MainWidget::currentuser == allinfo.at(i).at(0)){ //可以设置lineEdit的当前显示文字 ui->lineEdit_1->setText(allinfo.at(i).at(0)); ui->lineEdit_2->setText(allinfo.at(i).at(1)); ui->lineEdit_3->setText(allinfo.at(i).at(2)); ui->lineEdit_4->setText(allinfo.at(i).at(3)); ui->lineEdit_5->setText(allinfo.at(i).at(4)); ui->lineEdit_6->setText(allinfo.at(i).at(5)); ui->lineEdit_7->setText(allinfo.at(i).at(6)); ui->lineEdit_8->setText(allinfo.at(i).at(7)); ui->lineEdit_9->setText(allinfo.at(i).at(8)); } } } QVector<QVector<QString>> ChildWidgetG::queryAll(QString tablename) { if (! userDataBasePri::database.open()){//打开数据库 qCritical() << userDataBasePri::database.lastError().text(); } QSqlQuery query(userDataBasePri::database); //作为条件直接在数据库中查找 QString statement = QString("SELECT * FROM %1").arg(tablename);//记录属性字段名 query.exec(statement);//查询执行(声明); //QVector<T>是Qt普通容器类的一种。它将自己的每个对象存储在连续的内存中。能够使用索引號来高速訪问它们 QVector<QVector<QString>> retvector; QVector<QString> vectorstr; int midsize = 0; while(query.next()) { vectorstr.clear(); midsize = query.size(); for(int i = 0; i < 40;i++ ){ vectorstr.append(query.value(i).toByteArray()); } retvector.append(vectorstr); } userDataBasePri::database.close(); return retvector; } void ChildWidgetG::on_btn_resiger_clicked() { //输入:可以读取当前框中所输入的文字 QString tstr1 = ui->lineEdit_1->text(); QString tstr2 = ui->lineEdit_2->text(); QString tstr3 = ui->lineEdit_3->text(); QString tstr4 = ui->lineEdit_4->text(); QString tstr5 = ui->lineEdit_5->text(); QString tstr6 = ui->lineEdit_6->text(); QString tstr7 = ui->lineEdit_7->text(); QString tstr8 = ui->lineEdit_8->text(); QString tstr9 = ui->lineEdit_9->text(); if (! userDataBasePri::database.open()){//打开数据库 QXMessageBox message; //对话框 message.setlabelTitleStr("提示!"); message.setlabelMsgStr("数据库链接失败!"); message.exec(); qCritical() << userDataBasePri::database.lastError().text(); return; } QSqlQuery query(userDataBasePri::database); QString updataStr = QString("update teacher_information set teacher_name = '%2' " ", teacher_password = '%3' " ", teacher_sex = '%4' " ", teacher_age = '%5' " ", teacher_phone = '%6' " ", teacher_email = '%7' " ", teacher_level = '%8' " ", teacher_info = '%9' " "where teacherid = '%1'") .arg(tstr1).arg(tstr2).arg(tstr3) .arg(tstr4).arg(tstr5).arg(tstr6) .arg(tstr7).arg(tstr8).arg(tstr9); //arg函数应该是用参数替代字符串中的百分值,从小到大替换,%1--%99 bool ret = query.exec(updataStr); if (ret == false){//打开数据库 QXMessageBox message; message.setlabelTitleStr("提示!"); message.setlabelMsgStr("更新失败!"); message.exec(); }else{ QXMessageBox message; message.setlabelTitleStr("提示!"); message.setlabelMsgStr("更新成功!"); message.exec(); } userDataBasePri::database.close(); }
[ "2712104990@qq.com" ]
2712104990@qq.com
9e7fddb17de78f804780c0bdaedf48fd2dafa26c
db5e684f71b3ec765e62f5434a25020ca388ab84
/HttpProxyServer/HttpProxyServerDlg.cpp
938c6c9f8c8d1b891a5a35556e89187a73504895
[ "MIT" ]
permissive
xxxxnnxxxx/HttpProxy
279d4b7e6538727a94b2810a4cb72abdc01cadfb
697126dda1fca9fb46aeadfdc352fb2954757f98
refs/heads/master
2020-04-12T01:21:16.988564
2017-03-07T16:47:25
2017-03-07T16:47:25
62,365,123
23
7
null
2016-09-17T04:26:21
2016-07-01T05:22:45
C
GB18030
C++
false
false
6,173
cpp
// HttpProxyServerDlg.cpp : 实现文件 // #include "stdafx.h" #include "CommonFuncs.h" #include "HttpProxyServer.h" #include "HttpProxyServerDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialog { public: CAboutDlg(); // 对话框数据 enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() // CHttpProxyServerDlg 对话框 CHttpProxyServerDlg * theHPSDialog = NULL; CHttpProxyServerDlg::CHttpProxyServerDlg(CWnd* pParent /*=NULL*/) : CDialog(CHttpProxyServerDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); memset(&m_httpservice_params, 0, sizeof(HTTPSERVICE_PARAMS)); m_state = 0; } void CHttpProxyServerDlg::DoDataExchange(CDataExchange* pDX) { DDX_Control(pDX,IDC_LIST1,m_ctrl_requestlistbox); CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CHttpProxyServerDlg, CDialog) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CLOSE() ON_BN_CLICKED(IDC_BT_CONFIG,OnConfig) //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON1, &CHttpProxyServerDlg::OnBnClickedButton1) END_MESSAGE_MAP() // CHttpProxyServerDlg 消息处理程序 BOOL CHttpProxyServerDlg::OnInitDialog() { CDialog::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 ControlOpt(); theHPSDialog = this; m_ctrl_requestlistbox.ResetContent(); this->SetDlgItemInt(IDC_ET_PORT,8889); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CHttpProxyServerDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CHttpProxyServerDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CHttpProxyServerDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CHttpProxyServerDlg::ControlOpt() { switch (m_state) { case 0: { this->GetDlgItem(IDC_BT_CONFIG)->EnableWindow(TRUE); this->GetDlgItem(IDOK)->EnableWindow(FALSE); this->GetDlgItem(IDCANCEL)->EnableWindow(FALSE); } break; case STATE_STOP: { this->GetDlgItem(IDC_BT_CONFIG)->EnableWindow(FALSE); this->GetDlgItem(IDOK)->EnableWindow(TRUE); this->GetDlgItem(IDCANCEL)->EnableWindow(FALSE); } break; case STATE_START: { this->GetDlgItem(IDC_BT_CONFIG)->EnableWindow(FALSE); this->GetDlgItem(IDOK)->EnableWindow(FALSE); this->GetDlgItem(IDCANCEL)->EnableWindow(TRUE); } break; } } void __stdcall Request_Callback(PCALLBACK_DATA pcallback_data) { theHPSDialog->insert_reqlist(pcallback_data->buf,pcallback_data->len); } void __stdcall Response_Callback(PCALLBACK_DATA pcallback_data) { #ifdef _DEBUG // ::OutputDebugStringA("Default_Response_Callback\n"); #endif } //配置 void CHttpProxyServerDlg::OnConfig() { strcpy_s(m_httpservice_params.ip, 16, "127.0.0.1"); m_httpservice_params.port = (WORD)this->GetDlgItemInt(IDC_ET_PORT); m_httpservice_params.request_callback = Request_Callback; //m_httpservice_params.response_callback = Response_Callback; m_httpservice_params.bSSH = FALSE; m_hProxyHttpService = Create_ProxyHttpService(&m_httpservice_params); if (m_hProxyHttpService != NULL) { m_hSSLConfigHandle = Hijack_Https(m_hProxyHttpService); if (m_hSSLConfigHandle != NULL) { TrustRootCert(m_hSSLConfigHandle); m_state = STATE_STOP; } } ControlOpt(); } //启动 void CHttpProxyServerDlg::OnOK() { BOOL bRet = TRUE; bRet = Start_ProxyHttpService(m_hProxyHttpService); if (bRet) m_state = STATE_START; ControlOpt(); } //停止 void CHttpProxyServerDlg::OnCancel() { BOOL bRet = TRUE; bRet = Stop_ProxyHttpService(m_hProxyHttpService); if (bRet) m_state = STATE_STOP; ControlOpt(); } //关闭对话窗 void CHttpProxyServerDlg::OnClose() { this->EndDialog(0); } //测试 void CHttpProxyServerDlg::OnBnClickedButton1() { #ifdef _DEBUG Unittest(); #endif } void CHttpProxyServerDlg::insert_reqlist(const char* szurl, int len) { wchar_t *pws = NULL; CommonFuncs::a2w(szurl,&pws); m_ctrl_requestlistbox.AddString((LPCTSTR)pws); if( pws != NULL){ free(pws); } }
[ "xxxxnnxxxx@126.com" ]
xxxxnnxxxx@126.com
fe4213a35931cf9a5dd36d861a9017b99aa1bfc3
777a75e6ed0934c193aece9de4421f8d8db01aac
/src/Providers/UNIXProviders/DiagnosticServiceCapabilities/UNIX_DiagnosticServiceCapabilities_AIX.hxx
76e683187c5e4dd66207614df9652c600c1c8860
[ "MIT" ]
permissive
brunolauze/openpegasus-providers-old
20fc13958016e35dc4d87f93d1999db0eae9010a
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
refs/heads/master
2021-01-01T20:05:44.559362
2014-04-30T17:50:06
2014-04-30T17:50:06
19,132,738
1
0
null
null
null
null
UTF-8
C++
false
false
152
hxx
#ifdef PEGASUS_OS_AIX #ifndef __UNIX_DIAGNOSTICSERVICECAPABILITIES_PRIVATE_H #define __UNIX_DIAGNOSTICSERVICECAPABILITIES_PRIVATE_H #endif #endif
[ "brunolauze@msn.com" ]
brunolauze@msn.com
99b23ae2ce70a44acbbf77a245d257275340c942
561f1f3eb860795e322658667185a7e37ee5635d
/Piece.cpp
094e9d48b2cd15e86f0efd53ef087a6e7a4d7517
[]
no_license
Sabeehs/Sam-s-Chess
13fc07997ab9251de5fe64b277c609d190fe20d9
d654691a032d756378ce9c6c8e3c5bfd945bc0ef
refs/heads/master
2020-06-18T10:04:21.265923
2019-07-15T07:08:50
2019-07-15T07:08:50
196,264,311
0
1
null
2019-07-15T07:08:51
2019-07-10T19:32:42
C
UTF-8
C++
false
false
347
cpp
#include "Piece.h" Piece::Piece(int x, int y, int c, string n) : position({ x,y }), name(n), color(c), moves(0) { if (color == BLACK) disp = 0; else disp = 1; } void Piece::save(ostream& out) { out << position.x << " " << position.y << " " << color << " " << moves << endl; } int Piece::getColor() { return color; }
[ "noreply@github.com" ]
noreply@github.com
c339316de3adc0d890728ca4945109d0251f2a6e
fe6360bf697243c6c318836a3c64a9c1984b610b
/Eks3D/include/XAbstractDelegate.h
f6f514bf5130ef48b731544d371075383771c541
[]
no_license
davidmueller13/vexx
366cec96f4abac2e814176cd5d2ae75393561c0d
9194877951c78cd3fde3e7fbe6d511e40c24f8eb
refs/heads/master
2021-01-10T11:51:19.124071
2015-09-26T15:30:05
2015-09-26T15:30:05
43,210,604
0
0
null
null
null
null
UTF-8
C++
false
false
665
h
#ifndef XABSTRACTDELEGATE_H #define XABSTRACTDELEGATE_H #include "X3DGlobal.h" #include "XAbstractRenderModel.h" class XAbstractCanvas; class EKS3D_EXPORT XAbstractDelegate { public: virtual ~XAbstractDelegate(); virtual void update(const XAbstractCanvas *, const XAbstractRenderModel::Iterator *, const XAbstractRenderModel *) const { }; virtual void paint(xuint32 pass, XAbstractCanvas *, const XAbstractRenderModel::Iterator *, const XAbstractRenderModel *) const = 0; virtual xuint32 maxNumberOfPasses(XAbstractCanvas *, const XAbstractRenderModel::Iterator *, const XAbstractRenderModel *) const { return 1; } }; #endif // XABSTRACTDELEGATE_H
[ "jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9" ]
jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9
f7494701ceaa0e48d61a9cdc7550ae995de4c023
0f735afac2f581527c44ace5698050a6089bc28d
/extensions/devl/devl.cpp
b92c5c1e7ed3d7a26aa4fcc5a0c3404608df5fa2
[ "MIT" ]
permissive
mfkiwl/FlyDog_SDR_GPS
83db8d4990db7ee39188d7f6e5fc60c42cc865db
d4870af35e960282a3c1b7e6b41444be4cb53fab
refs/heads/master
2022-12-11T23:36:01.925673
2020-09-15T04:59:34
2020-09-15T04:59:34
296,168,529
11
4
MIT
2020-09-16T23:22:22
2020-09-16T23:22:22
null
UTF-8
C++
false
false
1,519
cpp
// Copyright (c) 2016 John Seamons, ZL/KF6VO #include "ext.h" // all calls to the extension interface begin with "ext_", e.g. ext_register() #include "kiwi.h" #include "spi.h" #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <math.h> #include <strings.h> //#define DEBUG_MSG true #define DEBUG_MSG false // rx_chan is the receiver channel number we've been assigned, 0..rx_chans // We need this so the extension can support multiple users, each with their own devl[] data structure. typedef struct { int rx_chan; int run; } devl_t; static devl_t devl[MAX_RX_CHANS]; bool devl_msgs(char *msg, int rx_chan) { devl_t *e = &devl[rx_chan]; int n; //printf("### devl_msgs RX%d <%s>\n", rx_chan, msg); if (strcmp(msg, "SET ext_server_init") == 0) { e->rx_chan = rx_chan; // remember our receiver channel number ext_send_msg(e->rx_chan, DEBUG_MSG, "EXT ready"); return true; } n = sscanf(msg, "SET run=%d", &e->run); if (n == 1) { return true; } int in_n; double in_f; n = sscanf(msg, "SET devl.in%d=%lf", &in_n, &in_f); if (n == 2) { //printf("DEVL: in%d=%lf\n", in_n, in_f); if (in_n == 1) { p0 = (int) lrint(in_f); } if (in_n == 2) { p1 = (int) lrint(in_f); } if (in_n == 3) { p2 = (int) lrint(in_f); } return true; } return false; } void devl_main(); ext_t devl_ext = { "devl", devl_main, NULL, devl_msgs, }; void devl_main() { ext_register(&devl_ext); }
[ "bclswl0827@gmail.com" ]
bclswl0827@gmail.com
b31e9cd6fe86fd5a049eed7776a0577823d5cc8a
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/tools/ragel6/mlgoto.h
50aeb32a2fc7ffa0a17179a602c4770b3f4d328b
[ "GPL-2.0-only", "Apache-2.0" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C++
false
false
3,035
h
/* * Copyright 2001-2006 Adrian Thurston <thurston@complang.org> * 2004 Erich Ocean <eric.ocean@ampede.com> * 2005 Alan West <alan@alanz.com> */ /* This file is part of Ragel. * * Ragel is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Ragel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Ragel; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _MLGOTO_H #define _MLGOTO_H #include <iostream> #include "mlcodegen.h" /* Forwards. */ //struct CodeGenData; //struct NameInst; //struct RedTransAp; //struct RedStateAp; //struct GenStateCond; /* * OCamlGotoCodeGen */ class OCamlGotoCodeGen : virtual public OCamlCodeGen { public: OCamlGotoCodeGen( ostream &out ) : OCamlCodeGen(out) {} std::ostream &TO_STATE_ACTION_SWITCH(); std::ostream &FROM_STATE_ACTION_SWITCH(); std::ostream &EOF_ACTION_SWITCH(); std::ostream &ACTION_SWITCH(); std::ostream &STATE_GOTOS(); std::ostream &TRANSITIONS(); std::ostream &EXEC_FUNCS(); std::ostream &FINISH_CASES(); void GOTO( ostream &ret, int gotoDest, bool inFinish ); void CALL( ostream &ret, int callDest, int targState, bool inFinish ); void NEXT( ostream &ret, int nextDest, bool inFinish ); void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish ); void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish ); void CURS( ostream &ret, bool inFinish ); void TARGS( ostream &ret, bool inFinish, int targState ); void RET( ostream &ret, bool inFinish ); void BREAK( ostream &ret, int targState ); virtual unsigned int TO_STATE_ACTION( RedStateAp *state ); virtual unsigned int FROM_STATE_ACTION( RedStateAp *state ); virtual unsigned int EOF_ACTION( RedStateAp *state ); std::ostream &TO_STATE_ACTIONS(); std::ostream &FROM_STATE_ACTIONS(); std::ostream &EOF_ACTIONS(); void COND_TRANSLATE( GenStateCond *stateCond, int level ); void emitCondBSearch( RedStateAp *state, int level, int low, int high ); void STATE_CONDS( RedStateAp *state, bool genDefault ); virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level ); void emitSingleSwitch( RedStateAp *state ); void emitRangeBSearch( RedStateAp *state, int level, int low, int high, RedTransAp* def ); /* Called from STATE_GOTOS just before writing the gotos */ virtual void GOTO_HEADER( RedStateAp *state ); virtual void STATE_GOTO_ERROR(); virtual void writeData(); virtual void writeExec(); }; #endif
[ "arcadia-devtools@yandex-team.ru" ]
arcadia-devtools@yandex-team.ru
2b933880441be36a60a46559da81da21c30e1885
cca8452efb93aeee303d107531ff6f823a303171
/src/SoundEngine/Trace/Trace.h
3d21c050f52b9a3fe91fec3d3cf6073e104f3d8d
[]
no_license
jcampbellcodes/flimEngine
96f852948fbb7f6a612b8d3acaf58867ad598ed9
dcf3205d08fefe244ee7813e370ae50f815f7ddc
refs/heads/master
2021-01-01T18:08:44.937007
2017-07-25T02:51:43
2017-07-25T02:51:43
98,254,393
5
1
null
null
null
null
UTF-8
C++
false
false
730
h
//----------------------------------------------------------------------------- // Copyright Ed Keenan 2016 // Optimized C++ //----------------------------------------------------------------------------- #ifndef DEBUG_OUTPUT_H #define DEBUG_OUTPUT_H #define TraceBuffSize 256 // NOTE: you need to set your project settings // Character Set -> Use Multi-Byte Character Set // Singleton helper class class Trace { public: // displays a printf to the output window static void out(char* fmt, ...); // Big four Trace() = default; Trace(const Trace &) = default; Trace & operator = (const Trace &) = default; ~Trace() = default; private: static Trace *privGetInstance(); char privBuff[TraceBuffSize]; }; #endif
[ "jackwcampbell@gmail.com" ]
jackwcampbell@gmail.com
7cda09f8bd0addd42d4eeac9c0499ee359ad426c
5639d4a766288aef8ab9ce61fc1ded63c21e359b
/qtmvt.hpp
d353cb821d43825271010a8365b9f5fad8543e6a
[]
no_license
romariorios/QtMVT
8070d80384d32a51eb7ce697c30024804b1537c8
5ee8c09f3c69d03a0db96390a419d9f32da5eb7d
refs/heads/master
2021-12-03T00:28:15.543151
2021-11-07T04:01:47
2021-11-07T04:01:47
33,547,242
7
1
null
null
null
null
UTF-8
C++
false
false
18,235
hpp
/* Qt Model/View Templates Copyright (c) 2015--2016 Luiz Romário Santana Rios <luizromario@gmail.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef LISTMODEL_HPP #define LISTMODEL_HPP // Qt includes #include <QAbstractTableModel> #include <QHash> // STL includes #include <array> #include <initializer_list> #include <functional> #include <utility> #include <tuple> #include <type_traits> using std::make_tuple; namespace QtMVT { namespace Util { template <typename T, typename... Types> class TypesAreDefaultConstructible { public: static const bool value = std::is_default_constructible<T>::value && TypesAreDefaultConstructible<Types...>::value; }; template <typename T> class TypesAreDefaultConstructible<T> { public: static const bool value = std::is_default_constructible<T>::value; }; } namespace Model { template <int I, typename... Types> class ListDataAccess; template <bool B, typename... Types> class ListInsertRows; namespace Util { template <typename RoleType> struct RoleFunctions { RoleFunctions( QHash<int, std::function<QVariant(const RoleType &)>> &&roles = { {Qt::DisplayRole, [](const RoleType &t) { return t; }} }, QHash<int, std::function<bool(RoleType &, const QVariant &)>> &&editRoles = {}) : roles{roles}, editRoles{editRoles} {} QVariant data(int role, const RoleType &t) const { if (!roles.contains(role)) { if (role != Qt::EditRole) return {}; role = Qt::DisplayRole; } return roles[role](t); } bool isEditable() const { return !editRoles.empty(); } bool setData(int role, RoleType &t, const QVariant &value) { if (!editRoles.contains(role)) return false; return editRoles[role](t, value); } QHash<int, std::function<QVariant(const RoleType &)>> roles; QHash<int, std::function<bool(RoleType &, const QVariant &)>> editRoles; }; } // A list with a fixed number of columns template <typename... Types> class List : public QAbstractTableModel { static_assert( sizeof...(Types) > 0, "Cannot instantiate QtMVT::Model::List with no template arguments"); typedef std::tuple<Types...> _RowType; public: static const constexpr int rowSize = std::tuple_size<_RowType>::value; List( std::array<const char *, rowSize> &&headerTitles, std::initializer_list<std::tuple<Types...>> &&l, Util::RoleFunctions<Types> &&... roles, QObject *parent = nullptr) : QAbstractTableModel{parent}, _headerTitles(std::move(headerTitles)), _rows{l}, _roleFunctions{roles...} {} List( std::array<const char *, rowSize> &&headerTitles, std::initializer_list<std::tuple<Types...>> &&l, std::function<QVariant(const Types &)> &&... displayFunctions, std::function<bool(Types &, const QVariant &)> &&... editFunctions, QObject *parent = nullptr) : List{ std::move(headerTitles), std::move(l), { {{Qt::DisplayRole, displayFunctions}}, {{Qt::EditRole, editFunctions}} }..., parent} {} List( std::array<const char *, rowSize> &&headerTitles, std::initializer_list<std::tuple<Types...>> &&l, std::function<QVariant(const Types &)> &&... displayFunctions, QObject *parent = nullptr) : List{ std::move(headerTitles), std::move(l), { {{Qt::DisplayRole, displayFunctions}}, {} }..., parent} {} List( std::array<const char *, rowSize> &&headerTitles, std::initializer_list<std::tuple<Types...>> &&l = {}, QObject *parent = nullptr) : List{ std::move(headerTitles), std::move(l), Util::RoleFunctions<Types>()..., parent} {} List(QObject *parent = nullptr) : List{{}, {}, parent} {} List(const List<Types...> &other, QObject *parent = nullptr) : QAbstractTableModel{parent}, _headerTitles(other._headerTitles), _rows{other._rows}, _roleFunctions{other._roleFunctions} {} List(List<Types...> &&) = default; List<Types...> createNew( std::initializer_list<_RowType> &&l = {}, QObject *parent = nullptr) { return {_headerTitles, std::move(l), _roleFunctions, parent}; } List<Types...> createNew(QObject *parent) { return createNew({}, parent); } int rowCount(const QModelIndex & = {}) const { return _rows.size(); } int columnCount(const QModelIndex & = {}) const { return std::tuple_size<_RowType>::value; } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { if (_indexIsInvalid(index)) return {}; return ListDataAccess<rowSize - 1, Types...>::getFromIndex(*this, index, role); } QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const { if ( section < 0 || section >= rowSize || orientation != Qt::Horizontal || role != Qt::DisplayRole) return QAbstractTableModel::headerData(section, orientation, role); return _headerTitles[section]; } Qt::ItemFlags flags(const QModelIndex &index) const { return QAbstractTableModel::flags(index) | (ListDataAccess<rowSize - 1, Types...>::columnIsEditable(*this, index.column())? Qt::ItemIsEditable : Qt::NoItemFlags); } bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) { if (_indexIsInvalid(index)) return {}; return ListDataAccess<rowSize - 1, Types...>::setInIndex(*this, index, value, role); } bool insertRows(int row, int count, const QModelIndex &parent = {}) { return ListInsertRows< QtMVT::Util::TypesAreDefaultConstructible<Types...>::value, Types...>::func(*this, row, count, parent); } bool removeRows(int row, int count, const QModelIndex &parent = {}) { if (count == 0) return true; if (row < 0 || static_cast<size_t>(row + count) > _rows.size()) return false; beginRemoveRows(parent, row, row + count - 1); auto rowIt = _rows.begin() + row; for (int i = 0; i < count; ++i) _rows.erase(rowIt); endRemoveRows(); return true; } const std::tuple<Types...> &row(int rowIndex) const { Q_ASSERT(rowIndex >= 0 && rowIndex < _rows.size()); return _rows[rowIndex]; } bool insert(int row, std::initializer_list<_RowType> &&rows) { if (rows.size() == 0) return true; if ( row < 0 || static_cast<size_t>(row) > _rows.size()) return false; beginInsertRows({}, row, row + rows.size() - 1); auto rowIt = _rows.begin() + row; _rows.insert(rowIt, rows); endInsertRows(); return true; } bool insert(int row, _RowType &&rowElements) { return insert(row, {std::move(rowElements)}); } bool append(std::initializer_list<_RowType> &&rows) { return insert(_rows.size(), std::move(rows)); } bool append(_RowType &&rowElements) { return append({std::move(rowElements)}); } template <std::size_t Column> void addRoleFunction( int role, std::function< QVariant( const typename std::tuple_element< Column, _RowType >::type &)> &&function) { beginResetModel(); auto &functions = std::get<Column>(_roleFunctions).roles; functions.insert(role, function); endResetModel(); } template <std::size_t Column> void addRoleFunction( std::function< QVariant( const typename std::tuple_element< Column, _RowType >::type &)> &&function) { addRoleFunction<Column>(Qt::DisplayRole, std::move(function)); } template <std::size_t Column> void addEditRoleFunction( int editRole, std::function< bool( typename std::tuple_element< Column, _RowType >::type &, const QVariant &)> &&function) { beginResetModel(); auto &functions = std::get<Column>(_roleFunctions).editRoles; functions.insert(editRole, function); endResetModel(); } template <std::size_t Column> void addEditRoleFunction( std::function< bool( typename std::tuple_element< Column, _RowType >::type &, const QVariant &)> &&function) { addEditRoleFunction<Column>(Qt::EditRole, std::move(function)); } template <std::size_t Column> void removeRole(int role = Qt::DisplayRole) { beginResetModel(); auto &functions = std::get<Column>(_roleFunctions).roles; functions.remove(role); endResetModel(); } template <std::size_t Column> void removeEditRole(int role = Qt::EditRole) { beginResetModel(); auto &functions = std::get<Column>(_roleFunctions).editRoles; functions.remove(role); endResetModel(); } void setHeaderTitle(int section, const char *title) { _headerTitles[section] = title; } private: inline bool _indexIsInvalid(const QModelIndex &index) const { return !index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() < 0 || index .column() >= columnCount(); } std::array<const char *, rowSize> _headerTitles; std::vector<_RowType> _rows; std::tuple<Util::RoleFunctions<Types>...> _roleFunctions; List( const decltype(_headerTitles) &headerTitles, std::initializer_list<_RowType> &&l, const decltype(_roleFunctions) &roleFunctions, QObject *parent) : QAbstractTableModel{parent}, _headerTitles(std::move(headerTitles)), _rows{l}, _roleFunctions{roleFunctions} {} template <int I, typename... ListTypes> friend class ListDataAccess; template <bool B, typename... ListTypes> friend class ListInsertRows; }; template <int I, typename... Types> class ListDataAccess { public: static QVariant getFromIndex(const List<Types...> &list, const QModelIndex &i, int role) { if (i.column() != I) return ListDataAccess<I - 1, Types...>::getFromIndex(list, i, role); return std::get<I>(list._roleFunctions).data( role, std::get<I>(list._rows[i.row()])); } static bool columnIsEditable(const List<Types...> &list, const int &column) { if (column != I) return ListDataAccess<I - 1, Types...>::columnIsEditable(list, column); return std::get<I>(list._roleFunctions).isEditable(); } static bool setInIndex(List<Types...> &list, const QModelIndex &i, const QVariant &data, const int &role) { if (i.column() != I) return ListDataAccess<I - 1, Types...>::setInIndex(list, i, data, role); return std::get<I>(list._roleFunctions).setData( role, std::get<I>(list._rows[i.row()]), data); } }; template <typename... Types> class ListDataAccess<-1, Types...> { public: static QVariant getFromIndex(const List<Types...> &, const QModelIndex &, int) { return {}; } static bool columnIsEditable(const List<Types...> &, const int &) { return false; } static bool setInIndex(List<Types...> &, const QModelIndex &, const QVariant &, const int &) { return false; } }; template <bool DefaultConstructible, typename... Types> class ListInsertRows; template <typename... Types> class ListInsertRows<true, Types...> { public: static bool func(List<Types...> &l, int row, int count, const QModelIndex &parent) { if (count == 0) return true; if (row < 0 || static_cast<size_t>(row) > l._rows.size()) return false; l.beginInsertRows(parent, row, row + count - 1); auto rowIt = l._rows.begin() + row; for (int i = 0; i < count; ++i) l._rows.emplace(rowIt); l.endInsertRows(); return true; } }; template <typename... Types> class ListInsertRows<false, Types...> { public: static bool func(List<Types...> &l, int row, int count, const QModelIndex &parent) { return static_cast<QAbstractTableModel &>(l).insertRows(row, count, parent); } }; template <typename T> class Table : public QAbstractTableModel { public: Table( const std::initializer_list<std::vector<T>> &l, Util::RoleFunctions<T> &&roleFunctions, QObject *parent = nullptr) : QAbstractTableModel{parent}, _roleFunctions{roleFunctions} { for(auto &&r : l) { if (r.size() > _width) _width = r.size(); _table.emplace_back(); auto &tableRow = *(_table.end() - 1); int i = 0; for (auto &&el : r) tableRow[i++] = el; } } inline int rowCount(const QModelIndex &) const { return _table.size(); } inline int columnCount(const QModelIndex &) const { return _width; } QVariant data(const QModelIndex &index, int role) const { if (!indexIsValid(index)) return {}; auto &row = _table[index.row()]; const auto columnInd = index.column(); if (columnInd >= row.size()) return {}; return _roleFunctions.data(role, row[index.column()]); } private: bool indexIsValid(const QModelIndex &index) const { return index.isValid() || static_cast<size_t>(index.row()) < _table.size() || static_cast<size_t>(index.column()) < _width; } std::vector<QHash<int, T>> _table; size_t _width = 0; Util::RoleFunctions<T> _roleFunctions; }; } } #endif // LISTMODEL_HPP
[ "luizromario@gmail.com" ]
luizromario@gmail.com
56ce9f66263b1188d5bcc4411870ba2c5645bab6
98b259ecd2782af015547d03e3f5da9cd80c31ac
/Risk/player.cpp
eae22627fd8eb74b3f590ae947681fb1755912b8
[]
no_license
mi15405/Risk
773eb743f262c765f23e9457e10cbbddb9d47e9d
36fefdc88a56d7c15acddb704cf1f762fa63bfa6
refs/heads/master
2020-05-23T06:54:40.573524
2019-09-08T15:09:41
2019-09-08T15:09:41
186,668,186
0
0
null
null
null
null
UTF-8
C++
false
false
2,934
cpp
#include "player.h" Player::Player(QString name, QString color) : m_name(name), m_color(color), m_territories_number(0), m_bonus_tanks(0), m_wood_num(0), m_stone_num(0), m_metal_num(0) {} void Player::add_bonus_tanks(unsigned int number) { m_bonus_tanks += number; } void Player::remove_bonus_tanks(unsigned int number) { if (m_bonus_tanks < number) m_bonus_tanks = 0; else m_bonus_tanks -= number; } void Player::add_resource(const Resource& resource) { switch(resource) { case Resource::Wood: increase_wood(1); break; case Resource::Stone: increase_stone(1); break; case Resource::Metal: increase_metal(1); break; } } void Player::increase_territory_number(unsigned int number) { m_territories_number += number; } void Player::decrease_territory_number(unsigned int number) { m_territories_number -= number; } void Player::use_card_combination(CardCombination combination) { unsigned int bonus_tanks = m_cards.use_combination(combination); if (bonus_tanks > 0) m_bonus_tanks += bonus_tanks; } void Player::reset() { m_cards.clear(); set_territories_number(0); set_bonus_tanks(0); set_wood(0); set_metal(0); set_stone(0); } QString Player::name() { return m_name; } QString Player::color() { return m_color; } void Player::set_name(const QString& name) { m_name = name; } unsigned int Player::territories_number() { return m_territories_number; } void Player::set_territories_number(unsigned int territories_number) { m_territories_number = territories_number; } Cards& Player::cards() { return m_cards; } unsigned int Player::bonus_tanks() const { return m_bonus_tanks; } void Player::set_bonus_tanks(unsigned int number) { m_bonus_tanks = number; } void Player::set_metal(unsigned int num) { m_metal_num = num; } void Player::set_stone(unsigned int num) { m_stone_num = num; } void Player::set_wood(unsigned int num) { m_wood_num = num; } unsigned int Player::get_metal() const { return m_metal_num; } unsigned int Player::get_stone() const { return m_stone_num; } unsigned int Player::get_wood() const { return m_wood_num; } void Player::increase_metal(unsigned int num) { m_metal_num += num; } void Player::increase_stone(unsigned int num) { m_stone_num += num; } void Player::increase_wood(unsigned int num) { m_wood_num += num; } void Player::decrease_metal(unsigned int num) { if (m_metal_num < num) m_metal_num = 0; else m_metal_num -= num; } void Player::decrease_stone(unsigned int num) { if (m_stone_num < num) m_stone_num = 0; else m_stone_num -= num; } void Player::decrease_wood(unsigned int num) { if (m_wood_num < num) m_wood_num = 0; else m_wood_num -= num; }
[ "noreply@github.com" ]
noreply@github.com
74f82e136dcdad11b1694abb23f06fa66ab4be67
ac53e60719e7a3dd3831a7cb6e40477f2bd6787f
/client-main/Classes/commands/CommandSkill.h
f3dd22c971856a4a51ee2beb68b43edfdd3271fc
[]
no_license
pzhifeng/client-main
d54a48195fd647278afbfa12470799fca75d0f6c
58d0d9ef1d4a5975ed4b05f6adb307f5600c072b
refs/heads/master
2016-09-06T09:56:55.459710
2013-05-30T09:45:18
2013-05-30T09:45:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
253
h
#ifndef __client_main__CommandSkill__ #define __client_main__CommandSkill__ #include "cocos2d.h" #include "../core/Command.h" //======CommandSkill====== class CommandSkill :public Command { public: LayerUI* success(const char *data); }; #endif
[ "pzhifeng@gmail.com" ]
pzhifeng@gmail.com
07b2db37eee3e5a7c67672d11a12339445f0f377
1977f9600212a9d592f6f64f3b07aef8f995ef8d
/Problem Storage/ad hoc/Easy/Mathy xD/CF_Div2_359C.cpp
3c589cb6c8ae35ee96cccab9257580283cd9e5cd
[]
no_license
electro1rage/OJProblemsCodes
c307314405616df5b7ae81b7d117dfff3c439e97
e59fc218d1c74e7ee48c3b4d77bfc9a513596b83
refs/heads/master
2021-01-19T19:17:57.426644
2016-01-15T12:19:59
2016-01-15T12:19:59
27,917,163
0
0
null
null
null
null
UTF-8
C++
false
false
742
cpp
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for((i)=0;(i)<(int)(n);++(i)) const int MN = 101010; const int MOD = 1000000007; int get_pow(int x, long long p) { if (p == 0) return 1; if (p % 2) return 1LL * x * get_pow(1LL * x * x % MOD, p / 2) % MOD; return get_pow(1LL * x * x % MOD, p / 2); } int a[MN]; map<long long, int> m; int main() { int n, x, i; scanf("%d %d", &n, &x); long long sum = 0; REP(i, n) scanf("%d", a + i), sum += a[i]; REP(i, n) ++m[sum - a[i]]; long long ans; for (auto it = m.begin(); it != m.end(); ++it) { if (it->second % x == 0) { m[it->first + 1] += it->second / x; } else { ans = it->first; break; } } printf("%d\n", get_pow(x, min(ans, sum))); return 0; }
[ "mohammed.mm16@hotmail.com" ]
mohammed.mm16@hotmail.com
8798a94397d0653e8dabe3aeff965490063191fa
3086bce01e4d5506c84595e03b802d4629c175f9
/src/qt/slingroad.cpp
04b07e78b61de385e3f37f4a982f2de73ec9562a
[ "MIT" ]
permissive
coinkeeper/2015-06-22_19-18_sling
15cd65bc27491d74c9c8a2ab10ff27464a8e8298
0c2671e70fabc62d6b64ca8d900af4e23b0bf57b
refs/heads/master
2021-01-13T01:30:55.379636
2015-06-06T05:55:48
2015-06-06T05:55:48
37,869,469
0
0
null
null
null
null
UTF-8
C++
false
false
6,628
cpp
#include "slingroad.h" #include "ui_slingroad.h" #include "ui_interface.h" #include "market.h" #include "key.h" #include "base58.h" #include "marketlistingdetailsdialog.h" #include "init.h" #include "wallet.h" #include <QClipboard> #include <QMessageBox> SlingRoad::SlingRoad(QWidget *parent) : QWidget(parent), ui(new Ui::SlingRoad) { ui->setupUi(this); subscribeToCoreSignals(); ui->slingRoadHeaderLabel->setPixmap(QPixmap(":/images/slingroad")); updateCategories(); ui->buyButton->setEnabled(false); ui->viewDetailsButton->setEnabled(false); ui->copyAddressButton->setEnabled(false); lastPrice = 0; } SlingRoad::~SlingRoad() { unsubscribeFromCoreSignals(); delete ui; } void SlingRoad::on_categoriesListWidget_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous) { // get the selected category and filter the listings std::string cat = ui->categoriesListWidget->currentItem()->text().toStdString(); std::set<CSignedMarketListing> listings = mapListingsByCategory[cat]; ui->tableWidget->clearContents(); ui->tableWidget->setRowCount(0); LOCK(cs_markets); BOOST_FOREACH(CSignedMarketListing p, listings) { // only show if no buy requests bool bFound = false; BOOST_FOREACH(PAIRTYPE(const uint256, CBuyRequest)& b, mapBuyRequests) { if(b.second.listingId == p.GetHash()) { if(b.second.nStatus != LISTED || b.second.nStatus != BUY_REQUESTED) { bFound = true; } } } if(bFound) continue; // go to next item, this one someone is already buying // until, vendor, price, title QTableWidgetItem* untilItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat(p.listing.nCreated + (7 * 24 * 60 * 60)))); QTableWidgetItem* vendorItem = new QTableWidgetItem(QString::fromStdString(CBitcoinAddress(p.listing.sellerKey.GetID()).ToString())); QTableWidgetItem* priceItem = new QTableWidgetItem(QString::number(p.listing.nPrice / COIN, 'f', 8)); QTableWidgetItem* btcPriceItem = new QTableWidgetItem(QString::number( (p.listing.nPrice/COIN) * lastPrice, 'f', 8)); QTableWidgetItem* titleItem = new QTableWidgetItem(QString::fromStdString(p.listing.sTitle)); QTableWidgetItem* idItem = new QTableWidgetItem(QString::fromStdString(p.GetHash().ToString())); ui->tableWidget->insertRow(0); ui->tableWidget->setItem(0, 0, untilItem); ui->tableWidget->setItem(0, 1, vendorItem); ui->tableWidget->setItem(0, 2, priceItem); ui->tableWidget->setItem(0, 3, btcPriceItem); ui->tableWidget->setItem(0, 4, titleItem); ui->tableWidget->setItem(0, 5, idItem); } } void SlingRoad::updateCategories() { ui->categoriesListWidget->clear(); BOOST_FOREACH(PAIRTYPE(const std::string, std::set<CSignedMarketListing>)& p, mapListingsByCategory) { ui->categoriesListWidget->addItem(QString::fromStdString(p.first)); } } void SlingRoad::updateCategory(QString category) { if(category == "") return; // if the category list doesn't contain this one, add it bool bFound = false; for(int i = 0; i < ui->categoriesListWidget->count(); ++i) { QListWidgetItem* item = ui->categoriesListWidget->item(i); if(item->text() == category) { bFound = true; break; } } if(!bFound) { ui->categoriesListWidget->addItem(category); } } static void NotifyMarketCategory(SlingRoad *page, std::string category) { QString cat = QString::fromStdString(category); QMetaObject::invokeMethod(page, "updateCategory", Qt::QueuedConnection, Q_ARG(QString, cat)); } static void NotifyListingCancelled(SlingRoad *page) { } void SlingRoad::subscribeToCoreSignals() { // Connect signals to core uiInterface.NotifyMarketCategory.connect(boost::bind(&NotifyMarketCategory, this, _1)); uiInterface.NotifyListingCancelled.connect(boost::bind(&NotifyListingCancelled, this)); } void SlingRoad::unsubscribeFromCoreSignals() { // Disconnect signals from core uiInterface.NotifyMarketCategory.disconnect(boost::bind(&NotifyMarketCategory, this, _1)); uiInterface.NotifyListingCancelled.disconnect(boost::bind(&NotifyListingCancelled, this)); } void SlingRoad::on_tableWidget_itemSelectionChanged() { if(ui->tableWidget->selectedItems().count() > 0) { ui->buyButton->setEnabled(true); ui->viewDetailsButton->setEnabled(true); ui->copyAddressButton->setEnabled(true); } } void SlingRoad::on_buyButton_clicked() { QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string id = ui->tableWidget->item(r, 4)->text().toStdString(); uint256 idHash = uint256(id); // ask the user if they really want to put in a buy request QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Request Buy", "Are you sure you want to send a buy request for this item?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { CBuyRequest buyRequest; buyRequest.buyerKey = pwalletMain->GenerateNewKey(); buyRequest.listingId = idHash; buyRequest.nStatus = BUY_REQUESTED; buyRequest.requestId = buyRequest.GetHash(); SignBuyRequest(buyRequest, buyRequest.vchSig); ReceiveBuyRequest(buyRequest); buyRequest.BroadcastToAll(); uiInterface.NotifyBuyRequest(buyRequest); } } void SlingRoad::on_viewDetailsButton_clicked() { QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string id = ui->tableWidget->item(r, 4)->text().toStdString(); uint256 idHash = uint256(id); // show the detailed item listing dialog MarketListingDetailsDialog* md = new MarketListingDetailsDialog(this, idHash); md->exec(); } void SlingRoad::on_copyAddressButton_clicked() { QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedRows(); if(selected.count() == 0) return; QModelIndex index = selected.at(0); int r = index.row(); std::string address = ui->tableWidget->item(r, 1)->text().toStdString(); QApplication::clipboard()->setText(QString::fromStdString(address)); }
[ "dgslayer@yandex.com" ]
dgslayer@yandex.com
158eb3812876ccd7f7313456a4b152f720f868d4
10733f6387baed7c23e14cfed3a73f94fb82f481
/src/cscrollareaimage.h
a2a02d73841043ea6782d17924e740deab566196
[]
no_license
chocoball/MapEditor
3cace77d653c603066412843c14e824c1d100d81
6d01ddb2e0ccf483907023d9d2833e7381be843f
refs/heads/master
2020-08-11T17:33:54.811145
2011-09-09T07:09:55
2011-09-09T07:09:55
2,268,118
0
0
null
null
null
null
UTF-8
C++
false
false
349
h
#ifndef CSCROLLAREAIMAGE_H #define CSCROLLAREAIMAGE_H #include <QScrollArea> class CScrollAreaImage : public QScrollArea { Q_OBJECT public: explicit CScrollAreaImage(QWidget *parent = 0); signals: public slots: protected: void dragEnterEvent(QDragEnterEvent *event) ; void dropEvent(QDropEvent *event) ; }; #endif // CSCROLLAREAIMAGE_H
[ "shin_zephex@hotmail.com" ]
shin_zephex@hotmail.com
53544b98612ca532fd7885cc2f81c5ca763149c8
73a0f661f1423d63e86489d4b2673f0103698aab
/oneflow/api/python/remat/remat.cpp
b26734ca48419adf29c912b44c41e9c15041ac54
[ "Apache-2.0" ]
permissive
Oneflow-Inc/oneflow
4fc3e081e45db0242a465c4330d8bcc8b21ee924
0aab78ea24d4b1c784c30c57d33ec69fe5605e4a
refs/heads/master
2023-08-25T16:58:30.576596
2023-08-22T14:15:46
2023-08-22T14:15:46
81,634,683
5,495
786
Apache-2.0
2023-09-14T09:44:31
2017-02-11T06:09:53
C++
UTF-8
C++
false
false
3,898
cpp
/* Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include <pybind11/pybind11.h> #include "oneflow/api/python/of_api_registry.h" #include "oneflow/core/vm/remat/allocator.h" #include "oneflow/core/vm/remat/env.h" #include "oneflow/core/eager/eager_blob_object.h" #include "oneflow/core/framework/tensor.h" #include "oneflow/core/job/global_for.h" #include "oneflow/core/eager/tensor_storage.h" namespace py = pybind11; namespace oneflow { namespace { Maybe<vm::RematableTensorStorage> rematable_storage(const std::shared_ptr<one::Tensor>& tensor) { auto ret = std::dynamic_pointer_cast<vm::RematableTensorStorage>( JUST(tensor->eager_blob_object())->tensor_storage()); CHECK_NOTNULL_OR_RETURN(ret); return ret; } } // namespace ONEFLOW_API_PYBIND11_MODULE("remat", m) { m.def("is_in_memory", [](const std::shared_ptr<one::Tensor>& tensor) -> Maybe<bool> { return JUST(rematable_storage(tensor))->is_in_memory(); }); m.def("allocated_memory", [](const std::string& device_str) -> Maybe<size_t> { auto device = JUST(Device::ParseAndNew(device_str)); return Singleton<remat::AllocatorManager>::Get() ->CreateOrGetAllocator(device->enum_type(), device->device_id()) ->allocated_memory(); }); m.def("display", [](const std::string& device_str) -> Maybe<void> { auto device = JUST(Device::ParseAndNew(device_str)); Singleton<remat::AllocatorManager>::Get() ->CreateOrGetAllocator(device->enum_type(), device->device_id()) ->DisplayAllPieces(); return Maybe<void>::Ok(); }); m.def("remat", [](const std::shared_ptr<one::Tensor>& t) -> Maybe<void> { // TODO: an instruction JUST(rematable_storage(t))->Remat(); return Maybe<void>::Ok(); }); m.def("evict", [](const std::shared_ptr<one::Tensor>& t) -> Maybe<void> { // TODO: an instruction JUST(rematable_storage(t))->Evict(false); return Maybe<void>::Ok(); }); m.def("is_evictable", [](const std::shared_ptr<one::Tensor>& t) -> Maybe<bool> { return JUST(rematable_storage(t))->is_evictable(); }); m.def("disable_eviction", [](const std::shared_ptr<one::Tensor>& t) -> Maybe<void> { JUST(rematable_storage(t))->set_eviction_disabled(true); return Maybe<void>::Ok(); }); m.def("clear_compute_op", [](const std::shared_ptr<one::Tensor>& t) -> Maybe<void> { JUST(rematable_storage(t))->clear_compute_op(); return Maybe<void>::Ok(); }); m.def("clear_stats", []() { Singleton<remat::Env>::Get()->clear_stats(); }); m.def("forced_eviction_num", []() { return Singleton<remat::Env>::Get()->forced_eviction_num(); }); m.def("eager_eviction_num", []() { return Singleton<remat::Env>::Get()->eager_eviction_num(); }); m.def("recomputation_num", []() { return Singleton<remat::Env>::Get()->recomputation_num(); }); m.def("set_budget_in_bytes", [](size_t budget_in_bytes) { Singleton<remat::Env>::Get()->set_budget_in_bytes(budget_in_bytes); }); m.def("budget_in_bytes", []() { return Singleton<remat::Env>::Get()->budget_in_bytes(); }); m.def("set_small_pieces_optimization", [](bool enabled) { return Singleton<remat::Env>::Get()->set_small_pieces_optimization(enabled); }); m.def("is_small_pieces_optimization_enabled", []() { return Singleton<remat::Env>::Get()->is_small_pieces_optimization_enabled(); }); } } // namespace oneflow
[ "noreply@github.com" ]
noreply@github.com
4d3bb16a69d25aed904223b711816529ac3e2ee0
989fbdb229e8d8f93de4dd2e784c520ca837dd15
/include/openeaagles/graphics/Readouts.hpp
12478e16f7290d395d7dfa1fb661acc2870779eb
[]
no_license
gehldp/OpenEaagles
3ed7f37d91499067a64dae8fa5826a1e8e47d1f0
3f7964d007278792d5f7ac3645b3cd32c11008e3
refs/heads/master
2021-01-15T15:58:14.038678
2017-08-10T02:35:03
2017-08-10T02:35:03
2,516,276
0
0
null
null
null
null
UTF-8
C++
false
false
542
hpp
#ifndef __oe_graphics_Readouts_H__ #define __oe_graphics_Readouts_H__ // fields #include "./readouts/AsciiText.hpp" #include "./readouts/Cursor.hpp" #include "./readouts/Rotary.hpp" #include "./readouts/Rotary2.hpp" // readouts #include "./readouts/DirectionReadout.hpp" #include "./readouts/HexReadout.hpp" #include "./readouts/LatitudeReadout.hpp" #include "./readouts/LongitudeReadout.hpp" #include "./readouts/NumericReadout.hpp" #include "./readouts/OctalReadout.hpp" #include "./readouts/TimeReadout.hpp" #endif
[ "doug@openeaagles.org" ]
doug@openeaagles.org
6161b1ee5a52896bea19cb01b17f8be80a379ca5
cb71dcb4556911373e5367f5f3871a2d0d615533
/src/uint256.h
c79cc6a591562be67dd7f6a6b818a99645dc37ce
[ "MIT" ]
permissive
titaniumblockchain/titanium
17b9ae8754ce28f6b9aca082f6b373acc6ec57c1
b22ee2231e9f721a98ef486279add588240ad7b2
refs/heads/main
2023-06-03T03:57:22.219094
2021-07-02T18:06:20
2021-07-02T18:06:20
382,419,634
1
1
null
null
null
null
UTF-8
C++
false
false
4,217
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef ETITANIUM_UINT256_H #define ETITANIUM_UINT256_H #include <assert.h> #include <cstring> #include <stdint.h> #include <string> #include <vector> /** Template base class for fixed-sized opaque blobs. */ template<unsigned int BITS> class base_blob { protected: static constexpr int WIDTH = BITS / 8; uint8_t m_data[WIDTH]; public: /* construct 0 value by default */ constexpr base_blob() : m_data() {} /* constructor for constants between 1 and 255 */ constexpr explicit base_blob(uint8_t v) : m_data{v} {} explicit base_blob(const std::vector<unsigned char>& vch); bool IsNull() const { for (int i = 0; i < WIDTH; i++) if (m_data[i] != 0) return false; return true; } void SetNull() { memset(m_data, 0, sizeof(m_data)); } inline int Compare(const base_blob& other) const { return memcmp(m_data, other.m_data, sizeof(m_data)); } friend inline bool operator==(const base_blob& a, const base_blob& b) { return a.Compare(b) == 0; } friend inline bool operator!=(const base_blob& a, const base_blob& b) { return a.Compare(b) != 0; } friend inline bool operator<(const base_blob& a, const base_blob& b) { return a.Compare(b) < 0; } std::string GetHex() const; void SetHex(const char* psz); void SetHex(const std::string& str); std::string ToString() const; const unsigned char* data() const { return m_data; } unsigned char* data() { return m_data; } unsigned char* begin() { return &m_data[0]; } unsigned char* end() { return &m_data[WIDTH]; } const unsigned char* begin() const { return &m_data[0]; } const unsigned char* end() const { return &m_data[WIDTH]; } unsigned int size() const { return sizeof(m_data); } uint64_t GetUint64(int pos) const { const uint8_t* ptr = m_data + pos * 8; return ((uint64_t)ptr[0]) | \ ((uint64_t)ptr[1]) << 8 | \ ((uint64_t)ptr[2]) << 16 | \ ((uint64_t)ptr[3]) << 24 | \ ((uint64_t)ptr[4]) << 32 | \ ((uint64_t)ptr[5]) << 40 | \ ((uint64_t)ptr[6]) << 48 | \ ((uint64_t)ptr[7]) << 56; } template<typename Stream> void Serialize(Stream& s) const { s.write((char*)m_data, sizeof(m_data)); } template<typename Stream> void Unserialize(Stream& s) { s.read((char*)m_data, sizeof(m_data)); } }; /** 160-bit opaque blob. * @note This type is called uint160 for historical reasons only. It is an opaque * blob of 160 bits and has no integer operations. */ class uint160 : public base_blob<160> { public: constexpr uint160() {} explicit uint160(const std::vector<unsigned char>& vch) : base_blob<160>(vch) {} }; /** 256-bit opaque blob. * @note This type is called uint256 for historical reasons only. It is an * opaque blob of 256 bits and has no integer operations. Use arith_uint256 if * those are required. */ class uint256 : public base_blob<256> { public: constexpr uint256() {} constexpr explicit uint256(uint8_t v) : base_blob<256>(v) {} explicit uint256(const std::vector<unsigned char>& vch) : base_blob<256>(vch) {} static const uint256 ZERO; static const uint256 ONE; }; /* uint256 from const char *. * This is a separate function because the constructor uint256(const char*) can result * in dangerously catching uint256(0). */ inline uint256 uint256S(const char *str) { uint256 rv; rv.SetHex(str); return rv; } /* uint256 from std::string. * This is a separate function because the constructor uint256(const std::string &str) can result * in dangerously catching uint256(0) via std::string(const char*). */ inline uint256 uint256S(const std::string& str) { uint256 rv; rv.SetHex(str); return rv; } #endif // ETITANIUM_UINT256_H
[ "root@wallet.etitanium.net" ]
root@wallet.etitanium.net
d3632c838e6ea6e9a8cb307591f6094259436477
99820bfa01f8670efd53cc1e66b3b0c04d486232
/JREngine/HelloLighting/GameApp.h
832388f7614bfdeacfa55cf336c45bd3c8be362a
[]
no_license
JaboRoman/Math3DGraphics
7efe04f4301665d727b126d431283ccc31318cf6
2cbd32bc65200cd231508d51b20041a8aa7d344a
refs/heads/master
2022-02-28T00:47:32.139598
2018-06-19T22:21:41
2018-06-19T22:21:41
87,872,557
0
0
null
null
null
null
UTF-8
C++
false
false
1,496
h
#pragma once #include <Core\Inc\Core.h> #include <Input\Inc\Input.h> #include <Graphics\Inc\Graphics.h> class GameApp : public Core::Application { public: GameApp(); ~GameApp() override; private: void OnInitialize(uint32_t width, uint32_t height) override; void OnTerminate() override; void OnUpdate() override; struct Light // TODO: Add to Graphics library (i.e. Graphics::Light) { Light() : direction(Math::Vector3::ZAxis(), 0.0f) , ambient(Math::Vector4::White()) , diffuse(Math::Vector4::White()) , specular(Math::Vector4::White()) {} Math::Vector4 direction; Math::Vector4 ambient; Math::Vector4 diffuse; Math::Vector4 specular; }; struct Material // TODO: Add to Graphics library (i.e. Graphics::Material) { Material() : ambient(Math::Vector4::White()) , diffuse(Math::Vector4::White()) , specular(Math::Vector4::White()) , specularPower(0.0f) {} Math::Vector4 ambient; Math::Vector4 diffuse; Math::Vector4 specular; float specularPower; }; struct ConstantData { Math::Matrix4 wvp; }; Core::Window mWindow; Core::Timer mTimer; Graphics::Camera mCamera; Graphics::Transform mCameraTransform; Graphics::TypedConstantBuffer<ConstantData> mConstantBuffer; Graphics::MeshBuffer mMeshBuffer; Graphics::VertexShader mVertexShader; Graphics::PixelShader mPixelShader; Graphics::Texture mTexture; Graphics::Sampler mSampler; Graphics::Mesh mMesh; Graphics::MeshBuilder mMeshBuilder; Math::Vector3 mRotation; };
[ "0379321@LCIVAN-296-09.AIV.EDMC.STU" ]
0379321@LCIVAN-296-09.AIV.EDMC.STU
329fb86fc34c0847cfbba30e5b69b5a680fa41f5
fa85317d4cbd2854a16ec68f4078696046f20998
/BluetoothJoystick.h
f43ad68b7c35050564c2f5337a30cc8a2d725388
[]
no_license
teodor-stoenescu/flexybot
0a536d6e718bbae8e60cc3d337f595a01bd61fdb
1d9fbebaa638ba9ea504712eb716d14a7753a654
refs/heads/master
2021-01-19T11:20:45.552042
2015-06-18T05:59:15
2015-06-18T05:59:15
36,883,581
0
0
null
null
null
null
UTF-8
C++
false
false
5,249
h
#ifndef _BLUETOOTH_JOYSTICK_H #define _BLUETOOTH_JOYSTICK_H #if ARDUINO >= 100 #include "Arduino.h" #include "Print.h" #else #include "WProgram.h" #endif #include "SoftwareSerial.h" #define STX 0x02 #define ETX 0x03 #define SLOW 750 // Datafields refresh rate (ms) #define FAST 250 // Datafields refresh rate (ms) class BluetoothJoystick { protected : byte buttonStatus; // first Byte sent to Android device long sendInterval; // interval between Buttons status transmission (milliseconds) struct Variant { union { int asInt; float asFloat; String *asString; } data; byte type; }; virtual Variant *GetCustomField(byte idx) { return NULL; } virtual void ButtonNotification(byte bStatus) { } virtual void JoystickNotification(int joyX, int joyY) { } private : SoftwareSerial *port; byte cmd[8]; long previousMillis; // will store last time Buttons status was updated //String displayStatus = "lol"; // message to Android device String GetButtonStatusString() { String bStatus = ""; for (int i = 0; i < 6; i++) { bStatus += (buttonStatus & (B100000 >> i)) ? "1" : "0"; } return bStatus; } void SendCustomField(Variant *v) { if (NULL == v) { port->print("N/A"); } switch (v->type) { case 0: port->print(v->data.asInt); break; case 1: port->print(v->data.asFloat); break; case 2: port->print(*(v->data.asString)); break; } } void GetJoystickState(byte data[8]) { int joyX = (data[1] - 48) * 100 + (data[2] - 48) * 10 + (data[3] - 48); // obtain the Int from the ASCII representation int joyY = (data[4] - 48) * 100 + (data[5] - 48) * 10 + (data[6] - 48); joyX = joyX - 200; // Offset to avoid joyY = joyY - 200; // transmitting negative numbers if (joyX < -100 || joyX > 100 || joyY < -100 || joyY > 100) { return; // commmunication error } JoystickNotification(joyX, joyY); } void SendBluetoothData() { static long previousMillis = 0; long currentMillis = millis(); if (currentMillis - previousMillis > sendInterval) { // send data back to smartphone previousMillis = currentMillis; // Data frame transmitted back from Arduino to Android device: // < 0X02 Buttons state 0X01 DataField#1 0x04 DataField#2 0x05 DataField#3 0x03 > // < 0X02 "01011" 0X01 "120.00" 0x04 "-4500" 0x05 "Motor enabled" 0x03 > // example port->print((char)STX); // Start of Transmission port->print(GetButtonStatusString()); port->print((char)0x1); // buttons status feedback SendCustomField(GetCustomField(0)); port->print((char)0x4); // datafield #1 SendCustomField(GetCustomField(1)); port->print((char)0x5); // datafield #2 SendCustomField(GetCustomField(2)); // datafield #3 port->print((char)ETX); // End of Transmission } } public : BluetoothJoystick(SoftwareSerial *p) { port = p; memset(cmd, 0, sizeof(cmd)); buttonStatus = 0; previousMillis = 0; sendInterval = SLOW; } void Setup() { port->begin(115200); port->print("$"); port->print("$"); port->print("$"); delay(100); port->println("U,9600,N"); port->begin(9600); // Start bluetooth serial at 9600 // 57600 = max value for softserial } void Loop() { if (port->available()) { // data received from smartphone delay(2); cmd[0] = port->read(); if (cmd[0] == STX) { int i = 1; while (port->available()) { delay(1); cmd[i] = port->read(); if (cmd[i] > 127 || i > 7) { break; // Communication error } if ((cmd[i] == ETX) && (i == 2 || i == 7)) { break; // Button or Joystick data } i++; } if (i == 2) { ButtonNotification(cmd[1]); // 3 Bytes ex: < STX "C" ETX > } else if (i == 7) { GetJoystickState(cmd); // 6 Bytes ex: < STX "200" "180" ETX > } } } SendBluetoothData(); } }; #endif
[ "demonu.ro@gmail.com" ]
demonu.ro@gmail.com