本文整理汇总了C++中convert函数的典型用法代码示例。如果您正苦于以下问题:C++ convert函数的具体用法?C++ convert怎么用?C++ convert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int __cdecl main(int argc, char *argv[])
{
int neg = -42;
int pos = 0x1234ab;
INT64 l = 0x1234567887654321;
if (PAL_Initialize(argc, argv) != 0)
{
return(FAIL);
}
DoNumTest(convert("foo %x"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo %hx"), pos, convert("foo 34ab"));
DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab"));
DoI64NumTest(convert("foo %I64x"), l, "0x1234567887654321",
convert("foo 1234567887654321"));
DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab "));
DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab"));
DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab"));
DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab"));
DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo % x"), pos, convert("foo 1234ab"));
DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6"));
DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6"));
PAL_Terminate();
return PASS;
}
示例2: convert
CoordinateGps CoordinateConverter::convert(const QVector3D &c) const
{
return convert(Ogre::Vector3(c.x(), c.y(), c.z()));
}
示例3: convert
QMessageAccountId QMessageAccount::id() const
{
return convert(d_ptr->_account.id());
}
示例4: ParseCommandLine
void ParseCommandLine(const TCHAR *_cmdline) {
WideToACPConverter convert(_cmdline);
ParseCommandLine(convert);
}
示例5: convert
void PackedArgb::setArgb(const VectorArgb &argb)
{
m_argb = convert(argb.a, argb.r, argb.g, argb.b);
}
示例6: toZero
/// Starts of integer variable going to zero
inline int * toZero() const
{ convert(); return toZero_;}
示例7: main
int __cdecl main(int argc, char *argv[])
{
BOOL success = TRUE; /* assume success */
DWORD dwRet;
DWORD dwProcessId;
char szEventName[MAX_LONGPATH];
PWCHAR uniString;
if(0 != (PAL_Initialize(argc, argv)))
{
return FAIL;
}
/* Open the event to let test thread tell us to get started. */
uniString = convert(szcHelperProcessStartEvName);
hProcessStartEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString);
free(uniString);
if (!hProcessStartEvent)
{
Fail("helper.main: OpenEvent of '%S' failed (%u). "
"(the event should already exist!)\n",
szcHelperProcessStartEvName, GetLastError());
}
/* Wait for signal from test thread. */
dwRet = WaitForSingleObject(hProcessStartEvent, TIMEOUT);
if (dwRet != WAIT_OBJECT_0)
{
Fail("helper.main: WaitForSingleObject '%s' failed\n"
"LastError:(%u)\n", szcHelperProcessStartEvName, GetLastError());
}
dwProcessId = GetCurrentProcessId();
if ( 0 >= dwProcessId )
{
Fail ("helper.main: %s has invalid pid %d\n", argv[0], dwProcessId );
}
/* Open the event to tell test thread we are ready. */
if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessReadyEvName, dwProcessId) < 0)
{
Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId);
}
uniString = convert(szEventName);
hProcessReadyEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString);
free(uniString);
if (!hProcessReadyEvent)
{
Fail("helper.main: OpenEvent of '%s' failed (%u). "
"(the event should already exist!)\n",
szEventName, GetLastError());
}
/* Open the event to let test thread tell us to exit. */
if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessFinishEvName, dwProcessId) < 0)
{
Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId);
}
uniString = convert(szEventName);
hProcessFinishEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString);
free(uniString);
if (!hProcessFinishEvent)
{
Fail("helper.main: OpenEvent of '%s' failed LastError:(%u).\n",
szEventName, GetLastError());
}
/* Tell the test thread we are ready. */
if (!SetEvent(hProcessReadyEvent))
{
Fail("helper.main: SetEvent '%s' failed LastError:(%u)\n",
hProcessReadyEvent, GetLastError());
}
/* Wait for signal from test thread before exit. */
dwRet = WaitForSingleObject(hProcessFinishEvent, TIMEOUT);
if (WAIT_OBJECT_0 != dwRet)
{
Fail("helper.main: WaitForSingleObject '%s' failed pid=%d\n"
"LastError:(%u)\n",
szcHelperProcessFinishEvName, dwProcessId, GetLastError());
}
PEDANTIC(CloseHandle, (hProcessStartEvent));
PEDANTIC(CloseHandle, (hProcessReadyEvent));
PEDANTIC(CloseHandle, (hProcessFinishEvent));
PAL_Terminate();
return success ? PASS : FAIL;
}
示例8: GetParam
long L6470::getPos(){
unsigned long position = GetParam(ABS_POS);
return convert(position);
}
示例9: main
int
main(
int argc,
char *argv[]
)
{
FILE *fp;
int i, j;
progname = argv[0];
i = 1;
while (i < argc && argv[i][0] == '-') {
do {
switch (argv[i][1]) {
case 'i':
marker[nmarkers].usetype = USE_INSTANCE;
marker[nmarkers].objname = argv[++i];
break;
case 'I':
marker[nmarkers].usetype = USE_MESH;
marker[nmarkers].objname = argv[++i];
break;
case 'x':
marker[nmarkers].usetype = USE_XFORM;
marker[nmarkers].objname = argv[++i];
break;
case 'e':
expand = 1;
break;
case 'm':
marker[nmarkers].modout = argv[++i];
break;
case 's':
marker[nmarkers].mscale = atof(argv[++i]);
break;
default:
goto userr;
}
if (++i >= argc)
goto userr;
} while (argv[i][0] == '-');
if (marker[nmarkers].objname == NULL)
goto userr;
if (nmarkers >= MAXMARK) {
fprintf(stderr, "%s: too many markers\n", progname);
return 1;
}
marker[nmarkers++].modin = argv[i++];
marker[nmarkers].mscale = marker[nmarkers-1].mscale;
}
if (nmarkers == 0)
goto userr;
/* simple header */
putchar('#');
for (j = 0; j < i; j++) {
putchar(' ');
fputs(argv[j], stdout);
}
putchar('\n');
if (i == argc)
convert("<stdin>", stdin);
else
for ( ; i < argc; i++) {
if ((fp = fopen(argv[i], "r")) == NULL) {
perror(argv[i]);
exit(1);
}
convert(argv[i], fp);
fclose(fp);
}
return 0;
userr:
fprintf(stderr,
"Usage: %s [-e][-s size][-m modout] {-x objfile|-i octree|-I mesh} modname .. [file ..]\n",
progname);
return 1;
}
示例10: convert
void
VectorArrayAPI<T>::get_entry_mpz_class(int r, int c, mpz_class& value) const
{
convert(data[r][c], value);
}
示例11: convert
DeviceNameList DevicesI::getDevicelist(devicetype type,
const Ice::Current& /* current */) {
astro::module::Devices::devicelist devicelist
= _devices.getDevicelist(convert(type));
return convert(devicelist);
}
示例12: main
int main(int argc, char **argv)
{
const char *szTestFile;
FILE *f;
if (argc != 2) {
fprintf(stderr, "%s <test file>\n", argv[0]);
EXIT(1);
}
CRYPTO_malloc_debug_init();
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
szTestFile = argv[1];
f = fopen(szTestFile, "r");
if (!f) {
perror(szTestFile);
EXIT(2);
}
ERR_load_crypto_strings();
/* Load up the software EVP_CIPHER and EVP_MD definitions */
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
#ifndef OPENSSL_NO_ENGINE
/* Load all compiled-in ENGINEs */
ENGINE_load_builtin_engines();
#endif
#if 0
OPENSSL_config();
#endif
#ifndef OPENSSL_NO_ENGINE
/*
* Register all available ENGINE implementations of ciphers and digests.
* This could perhaps be changed to "ENGINE_register_all_complete()"?
*/
ENGINE_register_all_ciphers();
ENGINE_register_all_digests();
/*
* If we add command-line options, this statement should be switchable.
* It'll prevent ENGINEs being ENGINE_init()ialised for cipher/digest use
* if they weren't already initialised.
*/
/* ENGINE_set_cipher_flags(ENGINE_CIPHER_FLAG_NOINIT); */
#endif
for (;;) {
char line[4096];
char *p;
char *cipher;
unsigned char *iv, *key, *plaintext, *ciphertext, *aad, *tag;
int encdec;
int kn, in, pn, cn;
int an = 0;
int tn = 0;
if (!fgets((char *)line, sizeof line, f))
break;
if (line[0] == '#' || line[0] == '\n')
continue;
p = line;
cipher = sstrsep(&p, ":");
key = ustrsep(&p, ":");
iv = ustrsep(&p, ":");
plaintext = ustrsep(&p, ":");
ciphertext = ustrsep(&p, ":");
if (p[-1] == '\n') {
encdec = -1;
p[-1] = '\0';
tag = aad = NULL;
an = tn = 0;
} else {
aad = ustrsep(&p, ":");
tag = ustrsep(&p, ":");
if (tag == NULL) {
p = (char *)aad;
tag = aad = NULL;
an = tn = 0;
}
if (p[-1] == '\n') {
encdec = -1;
p[-1] = '\0';
} else
encdec = atoi(sstrsep(&p, "\n"));
}
kn = convert(key);
in = convert(iv);
pn = convert(plaintext);
cn = convert(ciphertext);
if (aad) {
an = convert(aad);
tn = convert(tag);
}
if (!test_cipher
(cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, aad, an,
tag, tn, encdec)
&& !test_digest(cipher, plaintext, pn, ciphertext, cn)) {
#ifdef OPENSSL_NO_AES
//.........这里部分代码省略.........
示例13: saved_scope
void cpp_typecheckt::convert(cpp_namespace_spect &namespace_spec)
{
// save the scope
cpp_save_scopet saved_scope(cpp_scopes);
const irep_idt &name=namespace_spec.get_namespace();
if(name=="")
{
// "unique namespace"
err_location(namespace_spec);
throw "unique namespace not supported yet";
}
irep_idt final_name(name);
std::string identifier=
cpp_identifier_prefix(current_mode)+"::"+
cpp_scopes.current_scope().prefix+id2string(final_name);
contextt::symbolst::const_iterator it=
context.symbols.find(identifier);
if(it!=context.symbols.end())
{
if(namespace_spec.alias().is_not_nil())
{
err_location(namespace_spec);
str << "namespace alias `" << final_name
<< "' previously declared" << std::endl;
str << "location of previous declaration: "
<< it->second.location;
throw 0;
}
if(it->second.type.id()!="namespace")
{
err_location(namespace_spec);
str << "namespace `" << final_name
<< "' previously declared" << std::endl;
str << "location of previous declaration: "
<< it->second.location;
throw 0;
}
// enter that scope
cpp_scopes.set_scope(it->first);
}
else
{
symbolt symbol;
symbol.name=identifier;
symbol.base_name=final_name;
symbol.value.make_nil();
symbol.location=namespace_spec.location();
symbol.mode=current_mode;
symbol.module=module;
symbol.type=typet("namespace");
if(context.move(symbol))
throw "cpp_typecheckt::convert_namespace: context.move() failed";
cpp_scopes.new_namespace(final_name);
}
/*if(namespace_spec.alias().is_not_nil())
{
cpp_typecheck_resolvet resolver(*this);
cpp_scopet &s=resolver.resolve_namespace(namespace_spec.alias());
cpp_scopes.current_scope().add_using_scope(s);
}
else
{*/
// do the declarations
for(cpp_namespace_spect::itemst::iterator
it=namespace_spec.items().begin();
it!=namespace_spec.items().end();
it++)
convert(*it);
// }
}
示例14: fixEntries
/// Entries for fixing variables
inline cliqueEntry * fixEntries() const
{ convert(); return fixEntry_;}
示例15: main
int main(int argc, char **argv)
{
GDALAllRegister();
try
{
boost::timer::cpu_timer timer;
input_arguments parsed_args;
boost::program_options::options_description options_all("Fire Points to SciDB's Multidimensional Array Conversion Options");
options_all.add_options()
("version", "Print Fire Points to SciDB conversion tool version.\n")
("help", "Prints help message.\n")
("verbose", "Turns on verbose mode: prints timing and some more information about the conversion progress.\n")
("f", boost::program_options::value<std::string>(&parsed_args.source_file_name), "The source TIFF file to convert to SciDB's load format.\n")
("o", boost::program_options::value<std::string>(&parsed_args.target_file_name), "The target folder to store SciDB data file.\n")
("t", boost::program_options::value<int16_t>(&parsed_args.time_point), "The timeline position for the dataset.\n")
;
boost::program_options::variables_map options;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, options_all), options);
boost::program_options::notify(options);
if(options.count("help"))
{
std::cout << options_all << std::endl;
return EXIT_SUCCESS;
}
if(options.count("version"))
{
std::cout << "\n\nfocos2scidb version: " SCIETL_VERSION_STRING "\n" << std::endl;
return EXIT_SUCCESS;
}
parsed_args.verbose = options.count("verbose") ? true : false;
valid_args(parsed_args);
if(parsed_args.verbose)
std::cout << "\nfocos2scidb started\n" << std::endl;
convert(parsed_args);
if(parsed_args.verbose)
std::cout << "\n\nfocos2scidb finished successfully!\n" << std::endl;
}
catch(const std::exception& e)
{
std::cerr << "\n\nfocos2scidb finished with errors!\n";
if(e.what() != 0)
std::cerr << "\nAn unexpected error has occurried: " << e.what() << "\n";
std::cerr << "\nPlease, report it to [email protected]\n" << std::endl;
return EXIT_FAILURE;
}
catch(...)
{
std::cerr << "\n\nAn unexpected error has occurried with no additional information.\n" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}