本文整理汇总了C++中Array函数的典型用法代码示例。如果您正苦于以下问题:C++ Array函数的具体用法?C++ Array怎么用?C++ Array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _bind_methods
void PhysicsDirectSpaceState::_bind_methods() {
// ObjectTypeDB::bind_method(_MD("intersect_ray","from","to","exclude","umask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0));
// ObjectTypeDB::bind_method(_MD("intersect_shape:PhysicsShapeQueryResult","shape","xform","result_max","exclude","umask"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0));
ObjectTypeDB::bind_method(_MD("intersect_ray:Dictionary","from","to","exclude","layer_mask","type_mask"),&PhysicsDirectSpaceState::_intersect_ray,DEFVAL(Array()),DEFVAL(0x7FFFFFFF),DEFVAL(TYPE_MASK_COLLISION));
ObjectTypeDB::bind_method(_MD("intersect_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_intersect_shape,DEFVAL(32));
ObjectTypeDB::bind_method(_MD("cast_motion","shape:PhysicsShapeQueryParameters","motion"),&PhysicsDirectSpaceState::_cast_motion);
ObjectTypeDB::bind_method(_MD("collide_shape","shape:PhysicsShapeQueryParameters","max_results"),&PhysicsDirectSpaceState::_collide_shape,DEFVAL(32));
ObjectTypeDB::bind_method(_MD("get_rest_info","shape:PhysicsShapeQueryParameters"),&PhysicsDirectSpaceState::_get_rest_info);
BIND_CONSTANT( TYPE_MASK_STATIC_BODY );
BIND_CONSTANT( TYPE_MASK_KINEMATIC_BODY );
BIND_CONSTANT( TYPE_MASK_RIGID_BODY );
BIND_CONSTANT( TYPE_MASK_CHARACTER_BODY );
BIND_CONSTANT( TYPE_MASK_AREA );
BIND_CONSTANT( TYPE_MASK_COLLISION );
}
示例2: get_global_state
Array get_global_state() { return Array(); }
示例3: SET_FROM_STRUCT
void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_value) {
#define SET_FROM_STRUCT(m_type) \
{ \
GDMonoMarshal::M_##m_type from = MARSHALLED_OUT(m_type, p_value.operator ::m_type()); \
mono_field_set_value(p_object, mono_field, &from); \
}
#define SET_FROM_ARRAY(m_type) \
{ \
MonoArray *managed = GDMonoMarshal::m_type##_to_mono_array(p_value.operator ::m_type()); \
mono_field_set_value(p_object, mono_field, &managed); \
}
switch (type.type_encoding) {
case MONO_TYPE_BOOLEAN: {
MonoBoolean val = p_value.operator bool();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_CHAR: {
int16_t val = p_value.operator unsigned short();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I1: {
int8_t val = p_value.operator signed char();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I2: {
int16_t val = p_value.operator signed short();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I4: {
int32_t val = p_value.operator signed int();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_I8: {
int64_t val = p_value.operator int64_t();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U1: {
uint8_t val = p_value.operator unsigned char();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U2: {
uint16_t val = p_value.operator unsigned short();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U4: {
uint32_t val = p_value.operator unsigned int();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_U8: {
uint64_t val = p_value.operator uint64_t();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_R4: {
float val = p_value.operator float();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_R8: {
double val = p_value.operator double();
mono_field_set_value(p_object, mono_field, &val);
} break;
case MONO_TYPE_STRING: {
MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value);
mono_field_set_value(p_object, mono_field, mono_string);
} break;
case MONO_TYPE_VALUETYPE: {
GDMonoClass *tclass = type.type_class;
if (tclass == CACHED_CLASS(Vector2)) {
SET_FROM_STRUCT(Vector2);
break;
}
if (tclass == CACHED_CLASS(Rect2)) {
SET_FROM_STRUCT(Rect2);
break;
}
if (tclass == CACHED_CLASS(Transform2D)) {
SET_FROM_STRUCT(Transform2D);
break;
}
if (tclass == CACHED_CLASS(Vector3)) {
SET_FROM_STRUCT(Vector3);
break;
}
if (tclass == CACHED_CLASS(Basis)) {
SET_FROM_STRUCT(Basis);
break;
}
//.........这里部分代码省略.........
示例4: Array
Array SpriteFrames::_get_frames() const {
return Array();
}
示例5: test_28
bool test_28() {
OS::get_singleton()->print("\n\nTest 28: sprintf\n");
bool success, state = true;
char output_format[] = "\tTest:\t%ls => %ls (%s)\n";
String format, output;
Array args;
// %%
format = "fish %% frog";
args.clear();
output = format.sprintf(args);
success = (output == String("fish % frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
//////// INTS
// Int
format = "fish %d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args);
success = (output == String("fish 5 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int left padded with zeroes.
format = "fish %05d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args);
success = (output == String("fish 00005 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int left padded with spaces.
format = "fish %5d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args);
success = (output == String("fish 5 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int right padded with spaces.
format = "fish %-5d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args);
success = (output == String("fish 5 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int with sign (positive).
format = "fish %+d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args);
success = (output == String("fish +5 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Negative int.
format = "fish %d frog";
args.clear();
args.push_back(-5);
output = format.sprintf(args);
success = (output == String("fish -5 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Hex (lower)
format = "fish %x frog";
args.clear();
args.push_back(45);
output = format.sprintf(args);
success = (output == String("fish 2d frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Hex (upper)
format = "fish %X frog";
args.clear();
args.push_back(45);
output = format.sprintf(args);
success = (output == String("fish 2D frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Octal
format = "fish %o frog";
args.clear();
args.push_back(99);
output = format.sprintf(args);
success = (output == String("fish 143 frog"));
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
//.........这里部分代码省略.........
示例6: Array
void ObjectArrayIter::next() {
m_obj->o_invoke(s_next, Array(), -1);
}
示例7: hphp_context_init
bool HttpRequestHandler::executePHPRequest(Transport *transport,
RequestURI &reqURI,
SourceRootInfo &sourceRootInfo,
bool cachableDynamicContent) {
ExecutionContext *context = hphp_context_init();
context->setTransport(transport);
string file = reqURI.absolutePath().c_str();
{
ServerStatsHelper ssh("input");
HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo);
reqURI.clear();
sourceRootInfo.clear();
}
bool error = false;
std::string errorMsg = "Internal Server Error";
bool ret = hphp_invoke(context, file, false, Array(), null,
RuntimeOption::WarmupDocument,
RuntimeOption::RequestInitFunction,
error, errorMsg);
int code;
if (ret) {
std::string content = context->getContents();
if (cachableDynamicContent && !content.empty()) {
ASSERT(transport->getUrl());
string key = file + transport->getUrl();
DynamicContentCache::TheCache.store(key, content.data(), content.size());
}
code = 200;
transport->sendRaw((void*)content.data(), content.size());
} else if (error) {
code = 500;
string errorPage = context->getErrorPage();
if (errorPage.empty()) {
errorPage = RuntimeOption::ErrorDocument500;
}
if (!errorPage.empty()) {
context->obEndAll();
context->obStart();
context->obProtect(true);
ret = hphp_invoke(context, errorPage, false, Array(), null,
RuntimeOption::WarmupDocument,
RuntimeOption::RequestInitFunction,
error, errorMsg);
if (ret) {
std::string content = context->getContents();
transport->sendRaw((void*)content.data(), content.size());
} else {
errorPage.clear(); // so we fall back to 500 return
}
}
if (errorPage.empty()) {
if (RuntimeOption::ServerErrorMessage) {
transport->sendString(errorMsg, 500);
} else {
transport->sendString(RuntimeOption::FatalErrorMessage, 500);
}
}
} else {
code = 404;
transport->sendString("Not Found", 404);
}
transport->onSendEnd();
ServerStats::LogPage(file, code);
hphp_context_exit(context, true);
return ret;
}
示例8: php_globals_as_array
Array php_globals_as_array() {
return Array(get_global_variables()->asArrayData());
}
示例9: slice
Array Array::slice(int offset, int length, bool preserve_keys) const {
if (m_px == nullptr) return Array();
return ArrayUtil::Slice(m_px, offset, length, preserve_keys);
}
示例10: Array
Array Array::operator+(ArrayData *data) const {
return Array(m_px).operator+=(data);
}
示例11: godot_array_new_copy
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) {
Array *dest = (Array *)r_dest;
const Array *src = (const Array *)p_src;
memnew_placement(dest, Array(*src));
}
示例12: f_icu_match
Variant f_icu_match(CStrRef pattern, CStrRef subject,
VRefParam matches /* = null */, int64_t flags /* = 0 */) {
UErrorCode status = U_ZERO_ERROR;
if (matches.isReferenced()) {
matches = Array();
}
// Create hash map key by concatenating pattern and flags.
StringBuffer bpattern;
bpattern.append(pattern);
bpattern.append(':');
bpattern.append(flags);
String spattern = bpattern.detach();
// Find compiled pattern matcher in hash map or add it.
PatternStringMap::accessor accessor;
const RegexPattern* rpattern;
if (s_patternCacheMap.find(accessor, spattern.get())) {
rpattern = accessor->second;
} else {
// First 32 bits are reserved for ICU-specific flags.
rpattern = RegexPattern::compile(
UnicodeString::fromUTF8(pattern.data()), (flags & 0xFFFFFFFF), status);
if (U_FAILURE(status)) {
return false;
}
if (s_patternCacheMap.insert(
accessor, makeStaticString(spattern.get()))) {
accessor->second = rpattern;
} else {
delete rpattern;
rpattern = accessor->second;
}
}
// Build regex matcher from compiled pattern and passed-in subject.
UnicodeString usubject = UnicodeString::fromUTF8(subject.data());
boost::scoped_ptr<RegexMatcher> matcher(rpattern->matcher(usubject, status));
if (U_FAILURE(status)) {
return false;
}
// Return 0 or 1 depending on whether or not a match was found and
// (optionally), set matched (sub-)patterns for passed-in reference.
int matched = 0;
if (matcher->find()) {
matched = 1;
if (matches.isReferenced()) {
int32_t count = matcher->groupCount();
for (int32_t i = 0; i <= count; i++) {
UnicodeString ustring = matcher->group(i, status);
if (U_FAILURE(status)) {
return false;
}
// Convert UnicodeString back to UTF-8.
std::string string;
ustring.toUTF8String(string);
String match = String(string);
if (flags & k_UREGEX_OFFSET_CAPTURE) {
// start() returns the index in UnicodeString, which
// normally means the index into an array of 16-bit
// code "units" (not "points").
int32_t start = matcher->start(i, status);
if (U_FAILURE(status)) {
return false;
}
start = usubject.countChar32(0, start);
matches->append(make_packed_array(match, start));
} else {
matches->append(match);
}
}
}
}
return matched;
}
示例13: time
bool RPCRequestHandler::executePHPFunction(Transport *transport,
SourceRootInfo &sourceRootInfo) {
// reset timeout counter
ThreadInfo::s_threadInfo->m_reqInjectionData.started = time(0);
string rpcFunc = transport->getCommand();
{
ServerStatsHelper ssh("input");
RequestURI reqURI(rpcFunc);
HttpProtocol::PrepareSystemVariables(transport, reqURI, sourceRootInfo);
}
bool isFile = rpcFunc.rfind('.') != string::npos;
string rpcFile;
bool error = false;
Array params;
string sparams = transport->getParam("params");
if (!sparams.empty()) {
Variant jparams = f_json_decode(String(sparams), true);
if (jparams.isArray()) {
params = jparams.toArray();
} else {
error = true;
}
} else {
vector<string> sparams;
transport->getArrayParam("p", sparams);
if (!sparams.empty()) {
for (unsigned int i = 0; i < sparams.size(); i++) {
Variant jparams = f_json_decode(String(sparams[i]), true);
if (same(jparams, false)) {
error = true;
break;
}
params.append(jparams);
}
} else {
// single string parameter, used by xbox to avoid any en/decoding
int size;
const void *data = transport->getPostData(size);
if (data && size) {
params.append(String((char*)data, size, AttachLiteral));
}
}
}
if (transport->getIntParam("reset") == 1) {
m_reset = true;
}
int output = transport->getIntParam("output");
int code;
if (!error) {
Variant funcRet;
string errorMsg = "Internal Server Error";
string warmupDoc, reqInitFunc, reqInitDoc;
if (m_serverInfo) {
warmupDoc = m_serverInfo->getWarmupDoc();
reqInitFunc = m_serverInfo->getReqInitFunc();
reqInitDoc = m_serverInfo->getReqInitDoc();
}
if (!warmupDoc.empty()) warmupDoc = canonicalize_path(warmupDoc, "", 0);
if (!warmupDoc.empty()) {
warmupDoc = getSourceFilename(warmupDoc, sourceRootInfo);
}
if (!reqInitDoc.empty()) reqInitDoc = canonicalize_path(reqInitDoc, "", 0);
if (!reqInitDoc.empty()) {
reqInitDoc = getSourceFilename(reqInitDoc, sourceRootInfo);
}
bool runOnce = false;
bool ret = true;
if (isFile) {
rpcFile = rpcFunc;
rpcFunc.clear();
} else {
rpcFile = transport->getParam("include");
if (rpcFile.empty()) {
rpcFile = transport->getParam("include_once");
runOnce = true;
}
}
if (!rpcFile.empty()) {
// invoking a file through rpc
bool forbidden = false;
if (!RuntimeOption::ForbiddenFileExtensions.empty()) {
const char *ext = rpcFile.c_str() + rpcFile.rfind('.') + 1;
if (RuntimeOption::ForbiddenFileExtensions.find(ext) !=
RuntimeOption::ForbiddenFileExtensions.end()) {
forbidden = true;
}
}
if (!forbidden) {
rpcFile = canonicalize_path(rpcFile, "", 0);
rpcFile = getSourceFilename(rpcFile, sourceRootInfo);
ret = hphp_invoke(m_context, rpcFile, false, Array(), null,
warmupDoc, reqInitFunc, reqInitDoc,
error, errorMsg, runOnce);
//.........这里部分代码省略.........
示例14: readLine
Array File::readCSV(int64 length /* = 0 */, char delimiter_char /* = ',' */,
char enclosure_char /* = '"' */) {
String line = readLine(length);
if (line.empty()) {
return Array();
}
String new_line;
const char *buf = line.data();
int64 buf_len = line.size();
char *temp, *tptr, *line_end, *limit;
const char *bptr;
const char escape_char = '\\';
int64 temp_len, line_end_len;
bool first_field = true;
/* Now into new section that parses buf for delimiter/enclosure fields */
/* Strip trailing space from buf, saving end of line in case required
for enclosure field */
bptr = buf;
tptr = (char *)lookup_trailing_spaces(buf, buf_len);
line_end_len = buf_len - (size_t)(tptr - buf);
line_end = limit = tptr;
/* reserve workspace for building each individual field */
temp_len = buf_len;
temp = (char *)malloc(temp_len + line_end_len + 1);
/* Initialize return array */
Array ret;
/* Main loop to read CSV fields */
/* NB this routine will return a single null entry for a blank line */
do {
char *comp_end;
const char *hunk_begin;
tptr = temp;
/* 1. Strip any leading space */
for (; bptr < limit; ++bptr) {
if (!isspace((int)*(unsigned char *)bptr) || *bptr == delimiter_char) {
break;
}
}
if (first_field && bptr == line_end) {
ret.append(null_variant);
break;
}
first_field = false;
/* 2. Read field, leaving bptr pointing at start of next field */
if (bptr < limit && *bptr == enclosure_char) {
int state = 0;
bptr++; /* move on to first character in field */
hunk_begin = bptr;
/* 2A. handle enclosure delimited field */
int inc_len = 1;
for (;;) {
switch (inc_len) {
case 0:
switch (state) {
case 2:
memcpy(tptr, hunk_begin, bptr - hunk_begin - 1);
tptr += (bptr - hunk_begin - 1);
hunk_begin = bptr;
goto quit_loop_2;
case 1:
memcpy(tptr, hunk_begin, bptr - hunk_begin);
tptr += (bptr - hunk_begin);
hunk_begin = bptr;
/* break is omitted intentionally */
case 0:
{
if (hunk_begin != line_end) {
memcpy(tptr, hunk_begin, bptr - hunk_begin);
tptr += (bptr - hunk_begin);
hunk_begin = bptr;
}
/* add the embedded line end to the field */
memcpy(tptr, line_end, line_end_len);
tptr += line_end_len;
new_line = readLine(length);
const char *new_buf = new_line.data();
int64 new_len = new_line.size();
if (new_len == 0) {
/* we've got an unterminated enclosure,
* assign all the data from the start of
* the enclosure to end of data to the
* last element */
if ((size_t)temp_len > (size_t)(limit - buf)) {
//.........这里部分代码省略.........
示例15: Array
void DiscretizedVanillaOption::reset(Size size) {
values_ = Array(size, 0.0);
adjustValues();
}