本文整理汇总了C++中SAVE函数的典型用法代码示例。如果您正苦于以下问题:C++ SAVE函数的具体用法?C++ SAVE怎么用?C++ SAVE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SAVE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGD
/*
* Class: vision_thegraffter_VisionWrapper
* Method: processDatabaseCV
* Signature: (JFLvision/thegraffter/VisionWrapper/CornersRef;Lvision/thegraffter/VisionWrapper/StringRef;)V
*/
JNIEXPORT void JNICALL Java_vision_thegraffter_VisionWrapper_processDatabase
(JNIEnv *env, jobject, jlong matAddrGbr, jfloat reproj, jobject test_mycorners, jobject mystr) {
LOGD("--------------- PROCESS DATABASE ---------------");
cv::Mat &test_image = *(cv::Mat*)matAddrGbr;
old_locations.clear();
locations.clear();
std::string str;
wrapper.processFrame(test_image, old_locations, locations, str, reproj);
// Compute homography precision
float *test_corners = getCornersWrapper(env, test_mycorners);
std::map< unsigned, cv::Ptr<graffter::ObjLocation> >::iterator it;
for (it = locations.begin(); it != locations.end(); it++)
{
graffter::cvCorners projected_corners = it->second->getCorners();
float res = 0;
for (unsigned short j=0; j < projected_corners.size(); j++) {
cv::Point2f aux = cv::Point2f(test_corners[2*j], test_corners[(2*j)+1]);
res += cv::norm(aux - projected_corners[j]);
}
SAVE(str, it->second->getScale());
SAVE(str, it->second->getView());
SAVE(str, res);
LOGD("Model: %d -> %.2f\n", static_cast<int>(it->first), res);
}
setStringWrapper(env, mystr, str);
}
示例2: convert_string_list
/* convert_string_list return a list of strings. */
Handle convert_string_list(TaskData *mdTaskData, int count, char **strings)
{
Handle saved = mdTaskData->saveVec.mark();
Handle list = SAVE(ListNull);
/* It's simplest to process the strings in reverse order */
for (int i = count - 1; 0 <= i; i--)
{
/*
The order of these declarations is important, becaue we don't
want to have make to make the cons cell mutable. This is only
safe if we promise to initialise it fully before the next
ML heap allocation. SPF 29/11/96
*/
Handle value = SAVE(C_string_to_Poly(mdTaskData, strings[i]));
Handle next = alloc_and_save(mdTaskData, SIZEOF(ML_Cons_Cell));
DEREFLISTHANDLE(next)->h = DEREFWORDHANDLE(value);
DEREFLISTHANDLE(next)->t = DEREFLISTHANDLE(list);
/* reset save vector to stop it overflowing */
mdTaskData->saveVec.reset(saved);
list = SAVE(DEREFHANDLE(next));
}
return list;
}
示例3: enumerateRegistry
// Enumerate a key or a value. Returns a string option containing NONE if
// no key/value could be found or SOME s where s is the name of the key/value.
static Handle enumerateRegistry(TaskData *taskData, Handle args, HKEY hkey, BOOL isKey)
{
DWORD num = get_C_unsigned(taskData, DEREFWORDHANDLE(args)->Get(1));
LONG lRes;
TCHAR keyName[MAX_PATH];
DWORD dwLength = sizeof(keyName)/sizeof(keyName[0]);
Handle result, resVal;
if (isKey)
{
FILETIME ftMod;
lRes = RegEnumKeyEx(hkey, num, keyName, &dwLength, NULL, NULL, NULL, &ftMod);
if (lRes != ERROR_SUCCESS && lRes != ERROR_NO_MORE_ITEMS)
raise_syscall(taskData, "RegEnumKeyEx failed", -lRes);
}
else
{
lRes = RegEnumValue(hkey, num, keyName, &dwLength, NULL, NULL, NULL, NULL);
if (lRes != ERROR_SUCCESS && lRes != ERROR_NO_MORE_ITEMS)
raise_syscall(taskData, "RegEnumValue failed", -lRes);
}
if (lRes == ERROR_NO_MORE_ITEMS)
return SAVE(NONE_VALUE); /* NONE. */
resVal = SAVE(C_string_to_Poly(taskData, keyName));
result = alloc_and_save(taskData, 1);
DEREFHANDLE(result)->Set(0, DEREFWORDHANDLE(resVal));
return result;
}
示例4: SAVE
void Mission::MissionStep::save(gzFile file) const
{
SAVE(type);
target.save(file);
SAVE(flags);
SAVE(data);
}
示例5: queryRegistryKey
static Handle queryRegistryKey(TaskData *taskData, Handle args, HKEY hkey)
{
TCHAR valName[MAX_PATH];
byte *keyValue = 0;
LONG lRes;
DWORD valSize;
Handle result, resVal, resType;
DWORD dwType;
POLYUNSIGNED length = Poly_string_to_C(args->WordP()->Get(1), valName, MAX_PATH);
if (length > MAX_PATH)
raise_syscall(taskData, "Value name too long", ENAMETOOLONG);
// How long is the entry?
lRes = RegQueryValueEx(hkey, valName, 0, NULL, NULL, &valSize);
// When opening HKEY_PERFORMANCE_DATA we don't get a sensible
// answer here.
if (lRes == ERROR_MORE_DATA) valSize = 1024; // Guess
else if (lRes != ERROR_SUCCESS)
raise_syscall(taskData, "RegQueryValueEx failed", -lRes);
// Allocate that much store and get the value. We could
// try reading directly into ML store to save copying but
// it hardly seems worthwhile.
// Note: It seems that valSize can be zero for some items.
if (valSize == 0) resVal = SAVE(C_string_to_Poly(taskData, "", 0));
else
{
do {
byte *newAlloc = (byte*)realloc(keyValue, valSize);
if (newAlloc == 0)
{
free(keyValue);
raise_syscall(taskData, "Insufficient memory", ENOMEM);
}
keyValue = newAlloc;
lRes = RegQueryValueEx(hkey, valName, 0, &dwType, keyValue, &valSize);
// In the special case of HKEY_PERFORMANCE_DATA we may need to keep
// growing the buffer.
if (lRes == ERROR_MORE_DATA) valSize = valSize + 1024;
} while (lRes == ERROR_MORE_DATA);
if (lRes != ERROR_SUCCESS)
{
free(keyValue);
raise_syscall(taskData, "RegQueryValue failed", -lRes);
}
// If we have a string we have to convert this to ANSI/utf-8.
if (dwType == REG_SZ || dwType == REG_MULTI_SZ || dwType == REG_EXPAND_SZ)
resVal = SAVE(C_string_to_Poly(taskData, (TCHAR*)keyValue, valSize / sizeof(TCHAR)));
else resVal = SAVE(C_string_to_Poly(taskData, (char*)keyValue, valSize));
free(keyValue);
}
/* Create a pair containing the type and the value. */
resType = Make_arbitrary_precision(taskData, dwType);
result = alloc_and_save(taskData, 2);
DEREFHANDLE(result)->Set(0, DEREFWORDHANDLE(resType));
DEREFHANDLE(result)->Set(1, DEREFWORDHANDLE(resVal));
return result;
}
示例6: ShowParent
Handle ShowParent(TaskData *taskData, Handle hFileName)
// Return the name of the immediate parent stored in a child
{
TCHAR fileNameBuff[MAXPATHLEN+1];
POLYUNSIGNED length =
Poly_string_to_C(DEREFHANDLE(hFileName), fileNameBuff, MAXPATHLEN);
if (length > MAXPATHLEN)
raise_syscall(taskData, "File name too long", ENAMETOOLONG);
AutoClose loadFile(_tfopen(fileNameBuff, _T("rb")));
if ((FILE*)loadFile == NULL)
{
char buff[MAXPATHLEN+1+23];
#if (defined(_WIN32) && defined(UNICODE))
sprintf(buff, "Cannot open load file: %S", fileNameBuff);
#else
sprintf(buff, "Cannot open load file: %s", fileNameBuff);
#endif
raise_syscall(taskData, buff, errno);
}
SavedStateHeader header;
// Read the header and check the signature.
if (fread(&header, sizeof(SavedStateHeader), 1, loadFile) != 1)
raise_fail(taskData, "Unable to load header");
if (strncmp(header.headerSignature, SAVEDSTATESIGNATURE, sizeof(header.headerSignature)) != 0)
raise_fail(taskData, "File is not a saved state");
if (header.headerVersion != SAVEDSTATEVERSION ||
header.headerLength != sizeof(SavedStateHeader) ||
header.segmentDescrLength != sizeof(SavedStateSegmentDescr))
{
raise_fail(taskData, "Unsupported version of saved state file");
}
// Does this have a parent?
if (header.parentNameEntry != 0)
{
TCHAR parentFileName[MAXPATHLEN+1];
size_t toRead = header.stringTableSize-header.parentNameEntry;
if (MAXPATHLEN < toRead) toRead = MAXPATHLEN;
if (header.parentNameEntry >= header.stringTableSize /* Bad entry */ ||
fseek(loadFile, header.stringTable + header.parentNameEntry, SEEK_SET) != 0 ||
fread(parentFileName, 1, toRead, loadFile) != toRead)
{
raise_fail(taskData, "Unable to read parent file name");
}
parentFileName[toRead] = 0; // Should already be null-terminated, but just in case.
// Convert the name into a Poly string and then build a "Some" value.
// It's possible, although silly, to have the empty string as a parent name.
Handle resVal = SAVE(C_string_to_Poly(taskData, parentFileName));
Handle result = alloc_and_save(taskData, 1);
DEREFHANDLE(result)->Set(0, DEREFWORDHANDLE(resVal));
return result;
}
else return SAVE(NONE_VALUE);
}
示例7: unrrdu_ccfindMain
int
unrrdu_ccfindMain(int argc, char **argv, char *me, hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err, *valS;
Nrrd *nin, *nout, *nval=NULL;
airArray *mop;
int type, pret;
unsigned int conny;
hestOptAdd(&opt, "v,values", "filename", airTypeString, 1, 1, &valS, "",
"Giving a filename here allows you to save out the values "
"associated with each connect component. This can be used "
"later with \"ccmerge -d\". By default, no record of the "
"original CC values is kept.");
hestOptAdd(&opt, "t,type", "type", airTypeOther, 1, 1, &type, "default",
"type to use for output, to store the CC ID values. By default "
"(not using this option), the type used will be the smallest of "
"uchar, ushort, or int, that can represent all the CC ID values. "
"Using this option allows one to specify the integral type to "
"be used.",
NULL, NULL, &unrrduHestMaybeTypeCB);
hestOptAdd(&opt, "c,connect", "connectivity", airTypeUInt, 1, 1,
&conny, NULL,
"what kind of connectivity to use: the number of coordinates "
"that vary in order to traverse the neighborhood of a given "
"sample. In 2D: \"1\": 4-connected, \"2\": 8-connected");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_ccfindInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (nrrdCCFind(nout, airStrlen(valS) ? &nval : NULL, nin, type, conny)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error doing connected components:\n%s", me, err);
airMopError(mop);
return 1;
}
if (nval) {
airMopAdd(mop, nval, (airMopper)nrrdNuke, airMopAlways);
}
if (airStrlen(valS)) {
SAVE(valS, nval, NULL);
}
SAVE(out, nout, NULL);
airMopOkay(mop);
return 0;
}
示例8: ofs
void ConfigSerializer::Save(void)
{
try
{
std::ofstream ofs("Config.ini");
SAVE(Config::initialLevel);
SAVE(Config::showConsole);
SAVE(Config::startFullscreen);
SAVE(Config::loadPrefabsOnStart);
SAVE(Config::width);
SAVE(Config::height);
SAVE(Config::subloadLevel);
SAVE(Config::allowBarristaDebugStats);
SAVE(Config::vrMode);
LogVerbose("Wrote config", LogEntry::Command);
ofs.close();
}
catch (std::exception const& e)
{
Log("ERROR occurred during saving config: " + std::string(e.what()), LogEntry::Error);
}
}
示例9: create_dive_buffer
/*
* Note that we don't save the date and time or dive
* number: they are encoded in the filename.
*/
static void create_dive_buffer(struct dive *dive, struct membuffer *b)
{
put_format(b, "duration %u:%02u min\n", FRACTION(dive->dc.duration.seconds, 60));
SAVE("rating", rating);
SAVE("visibility", visibility);
cond_put_format(dive->tripflag == NO_TRIP, b, "notrip\n");
save_tags(b, dive->tag_list);
save_overview(b, dive);
save_cylinder_info(b, dive);
save_weightsystem_info(b, dive);
save_dive_temperature(b, dive);
}
示例10: Uequal
void Uequal ()
{ /* equal */
register AFFIX B = q->a;
register AFFIX A = (q - 1)->a;
affix x, y;
char *csave = c;
register char *xs = c, *ys;
q -= 2;
SAVE (x, A);
SAVE (y, B);
if (A == B)
{
CONTINUE;
}
else
{
if ((x.r == nil) && (x.l == nil))
xs = x.t;
else
{
sprinta (A);
A->t = xs;
A->l = nil;
A->r = nil;
*c++ = '\0';
}
ys = c;
if ((y.r == nil) && (y.l == nil))
ys = y.t;
else
{
sprinta (B);
B->t = ys;
B->l = nil;
B->r = nil;
*c++ = '\0';
}
if (afxcmp (xs, ys) == 0)
{
CONTINUE;
}
}
c = csave;
RESTORE (A, x);
RESTORE (B, y);
(q + 1)->a = A;
(q + 2)->a = B;
(q + 3)->q = Uequal;
q += 3;
}
示例11: constraintSatIso
static int
constraintSatIso(pullTask *task, pullPoint *point,
double stepMax, unsigned int iterMax,
/* output */
int *constrFailP) {
static const char me[]="constraintSatIso";
double
step, /* current step size */
val, aval, /* last and current function values */
hack, /* how to control re-tries in the context of a single
for-loop, instead of a nested do-while loop */
grad[4], dir[3], len, state[1 + 1 + 3 + 3];
unsigned int iter = 0; /* 0: initial probe, 1..iterMax: probes in loop */
PROBE(val, aval, grad);
SAVE(state, aval, val, grad, point->pos);
hack = 1;
for (iter=1; iter<=iterMax; iter++) {
/* consider? http://en.wikipedia.org/wiki/Halley%27s_method */
NORMALIZE(dir, grad, len);
if (!len) {
/* no gradient; back off */
hack *= task->pctx->sysParm.backStepScale;
RESTORE(aval, val, grad, point->pos, state);
continue;
}
step = -val/len; /* the newton-raphson step */
step = step > 0 ? AIR_MIN(stepMax, step) : AIR_MAX(-stepMax, step);
ELL_3V_SCALE_INCR(point->pos, hack*step, dir);
_pullPointHistAdd(point, pullCondConstraintSatA);
PROBE(val, aval, grad);
if (aval <= state[0]) { /* we're no further from the root */
if (AIR_ABS(step) < stepMax*task->pctx->sysParm.constraintStepMin) {
/* we have converged! */
break;
}
SAVE(state, aval, val, grad, point->pos);
hack = 1;
} else { /* oops, try again, don't update dir or len, reset val */
hack *= task->pctx->sysParm.backStepScale;
RESTORE(aval, val, grad, point->pos, state);
}
}
if (iter > iterMax) {
*constrFailP = pullConstraintFailIterMaxed;
} else {
*constrFailP = AIR_FALSE;
}
return 0;
}
示例12: SAVE
bool System::SaveRamSave(uint8 *dest, int maxsize) const
{
if (maxsize != SaveRamSize())
return false;
#define SAVE(sz,ptr) { if (sz) { std::memcpy(dest, (ptr), (sz)); dest += (sz); } }
SAVE(eeprom.ieeprom_size, eeprom.iEEPROM);
SAVE(eeprom.eeprom_size, eeprom.wsEEPROM);
SAVE(memory.sram_size, memory.wsSRAM);
#undef SAVE
return true;
}
示例13: LoadState
Handle LoadState(TaskData *taskData, Handle hFileName)
// Load a saved state file and any ancestors.
{
// Open the load file
TCHAR fileNameBuff[MAXPATHLEN];
POLYUNSIGNED length =
Poly_string_to_C(DEREFHANDLE(hFileName), fileNameBuff, MAXPATHLEN);
if (length > MAXPATHLEN)
raise_syscall(taskData, "File name too long", ENAMETOOLONG);
StateLoader loader(fileNameBuff);
// Request the main thread to do the load. This may set the error string if it failed.
processes->MakeRootRequest(taskData, &loader);
if (loader.errorResult != 0)
{
if (loader.errNumber == 0)
raise_fail(taskData, loader.errorResult);
else
{
char buff[MAXPATHLEN+100];
#if (defined(_WIN32) && defined(UNICODE))
sprintf(buff, "%s: %S", loader.errorResult, loader.fileName);
#else
sprintf(buff, "%s: %s", loader.errorResult, loader.fileName);
#endif
raise_syscall(taskData, buff, loader.errNumber);
}
}
return SAVE(TAGGED(0));
}
示例14: agetcwd
static Char *
agetcwd(void)
{
char *buf;
Char *cwd;
size_t len;
len = MAXPATHLEN;
buf = xmalloc(len);
while (getcwd(buf, len) == NULL) {
int err;
err = errno;
if (err != ERANGE) {
xfree(buf);
errno = err;
return NULL;
}
len *= 2;
buf = xrealloc(buf, len);
}
if (*buf == '\0') {
xfree(buf);
return NULL;
}
cwd = SAVE(buf);
xfree(buf);
return cwd;
}
示例15: unrrdu_flipMain
int
unrrdu_flipMain(int argc, char **argv, char *me, hestParm *hparm) {
hestOpt *opt = NULL;
char *out, *err;
Nrrd *nin, *nout;
int pret;
unsigned int axis;
airArray *mop;
OPT_ADD_AXIS(axis, "axis to flip along");
OPT_ADD_NIN(nin, "input nrrd");
OPT_ADD_NOUT(out, "output nrrd");
mop = airMopNew();
airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways);
USAGE(_unrrdu_flipInfoL);
PARSE();
airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways);
nout = nrrdNew();
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways);
if (nrrdFlip(nout, nin, axis)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error flipping nrrd:\n%s", me, err);
airMopError(mop);
return 1;
}
SAVE(out, nout, NULL);
airMopOkay(mop);
return 0;
}