本文整理汇总了C++中symbol类的典型用法代码示例。如果您正苦于以下问题:C++ symbol类的具体用法?C++ symbol怎么用?C++ symbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
typename boost::enable_if<boost::is_same<T, typename U::value_type>, void>::type
copy(symbol<T[]> const& src, U& dst)
{
function_requires<RandomAccessContainerConcept<U> >();
assert(typename U::difference_type(src.size()) == (dst.end() - dst.begin()));
CUDA_CALL(cudaMemcpyFromSymbol(&*dst.begin(), reinterpret_cast<char const*>(src.data()), src.size() * sizeof(T), 0, cudaMemcpyDeviceToHost));
}
示例2: copySymbol
// copy all symbol data from another symbol into a symbol from list
void reel::copySymbol(symbol temp, int offset)
{
// set the name of the symbol offset from the base of the list to the name of temp
list[offset].setName(temp.getName());
// set the value of the symbol offset from the base of the list to the value of temp
list[offset].setValue(temp.getValue());
};
示例3: split_name
bool split_name(symbol const& name, symbol & prefix, symbol & suffix) const {
if (name.is_numerical()) return false;
char const* str = name.bare_str();
char const* period = strchr(str,'.');
if (!period) return false;
svector<char> prefix_((unsigned)(period-str), str);
prefix_.push_back(0);
prefix = symbol(prefix_.c_ptr());
suffix = symbol(period + 1);
return true;
}
示例4:
symbol
Path::nodir (symbol name_s)
{
const std::string name = name_s.name ();
size_t start = name.size ();
for (;start > 0; start--)
{
const char prev = name[start-1];
if (prev == '/')
break;
#if !defined (__unix)
if (prev == '\\' || prev == ':')
break;
#endif // !unix
}
std::string result;
for (;start < name.size (); start++)
result += name[start];
return result;
}
示例5: pp_symbol
static unsigned pp_symbol(std::ostream & out, symbol const & s) {
if (is_smt2_quoted_symbol(s)) {
std::string str = mk_smt2_quoted_symbol(s);
out << str;
return static_cast<unsigned>(str.length());
}
else if (s.is_numerical()) {
std::string str = s.str();
out << str;
return static_cast<unsigned>(str.length());
}
else {
out << s.bare_str();
return static_cast<unsigned>(strlen(s.bare_str()));
}
}
示例6:
symbol_distribution::symbol_distribution(const symbol &s)
: total_frequencies(1) {
for (int i = 0; i < ARITHMETIC_SYMBOL_COUNT; i++) {
frequencies[i] = 0u;
}
frequencies[s.get_sequential_code()] = 1u;
}
示例7: if
bool
Path::set_directory (symbol directory_s)
{
const std::string& directory = directory_s.name ();
const char *const dir = directory.c_str ();
const bool result
= chdir (dir) == 0 || (mkdir (dir, 0777) == 0 && chdir (dir) == 0);
if (!result)
/* Do nothing */;
else if (directory[0] == '/'
#ifndef __unix__
|| directory[0] == '\\' || directory[1] == ':'
#endif
)
// Already absolute.
current_directory = directory;
else
// Make it absolute.
current_directory = get_cwd ();
std::ostringstream tmp;
tmp << "Changing directory to '" << directory << "' "
<< (result ? "success" : "failure");
Assertion::debug (tmp.str ());
return result;
}
示例8: get_directory
std::auto_ptr<std::istream>
Path::open_file (symbol name_s) const
{
const std::string& name = name_s.name ();
struct Message : std::ostringstream
{
~Message ()
{ Assertion::debug (this->str ()); }
} tmp;
tmp << "In directory '" << get_directory () << "':";
std::auto_ptr<std::istream> in;
// Absolute filename.
if (name[0] == '.' || name[0] == '/'
#ifndef __unix__
|| name[0] == '\\' || name[1] == ':'
#endif
)
{
tmp << "\nOpening absolute file name '" << name << "'";
in.reset (new std::ifstream (name.c_str ()));
return in;
}
tmp << "\nLooking for file '" << name << "'";
// Look in path.
for (unsigned int i = 0; i < path.size (); i++)
{
const symbol dir = (path[i] == "." ? current_directory : path[i]);
const symbol file = dir + DIRECTORY_SEPARATOR + name;
tmp << "\nTrying '" << file << "'";
if (path[i] == ".")
tmp << " (cwd)";
in.reset (new std::ifstream (file.name ().c_str ()));
if (in->good ())
{
tmp << " success!";
return in;
}
}
tmp << "\nGiving up";
daisy_assert (in.get ());
return in; // Return last bad stream.
}
示例9: ensure_quote
std::string ensure_quote(symbol const& s) {
std::string str;
if (is_smt2_quoted_symbol(s))
str = mk_smt2_quoted_symbol(s);
else
str = s.str();
return str;
}
示例10: print_alist
void
PrinterFile::Implementation::print_object (const FrameModel& value,
const Library& library,
const FrameModel *const original,
int indent)
{
const symbol element = value.type_name ();
if (!library.check (element))
{
out << "<unknown " << element << ">";
return;
}
// Check original.
if (original && original->type_name () == element)
{
out << "original";
// Check if we added something over the original.
if (value.subset (metalib, *original))
return;
out << " ";
print_alist (value, original, indent + 9, false);
return;
}
const FrameModel& element_frame = library.model (element);
// Check if we added something over the library.
if (value.subset (metalib, element_frame))
{
// We didn't.
print_symbol (element);
return;
}
// Library element with additional attributes.
print_symbol (element);
out << " ";
print_alist (value, &element_frame,
indent + 1 + element.name ().length ()
// Buglet: Wrong indentation for elements with strange chars.
+ (is_identifier (element.name ()) ? 0 : 2),
false);
}
示例11: get_accumulated_probability
double symbol_distribution::get_accumulated_probability(const symbol &s) const {
double result = 0.0;
for (unsigned int i = 0; i < s.get_sequential_code(); i++) {
result +=
static_cast<double>(frequencies[i]) /
static_cast<double>(total_frequencies);
}
return result;
}
示例12:
void
ChemistryMulti::check_ignore (const symbol chem, Treelog& msg)
{
if (ignored (chem))
return;
msg.message ("Fate of '" + chem.name () + "' will not be traced");
ignore.push_back (chem);
}
示例13: set_next_arg
void set_next_arg(cmd_context & ctx, symbol const & s) override {
cmd * c = ctx.find_cmd(s);
if (c == nullptr) {
std::string err_msg("unknown command '");
err_msg = err_msg + s.bare_str() + "'";
throw cmd_exception(std::move(err_msg));
}
m_cmds.push_back(s);
}
示例14: set_next_arg
virtual void set_next_arg(cmd_context & ctx, symbol const & s) {
cmd * c = ctx.find_cmd(s);
if (c == 0) {
std::string err_msg("unknown command '");
err_msg = err_msg + s.bare_str() + "'";
throw cmd_exception(err_msg);
}
m_cmds.push_back(s);
}
示例15:
void
DestinationTable::initialize (const symbol log_dir, const symbol objid,
const symbol description, const Volume& volume,
const std::vector<std::pair<symbol, symbol>/**/>&
/**/ parameters)
{
const std::string fn = log_dir.name () + file.name ();
out.open (fn.c_str ());
print_header.start (out, objid, file, parsed_from_file);
for (size_t i = 0; i < parameters.size (); i++)
print_header.parameter (out, parameters[i].first, parameters[i].second);
print_header.interval (out, volume);
print_header.log_description (out, description);
out.flush ();
}