本文整理汇总了C++中StringT类的典型用法代码示例。如果您正苦于以下问题:C++ StringT类的具体用法?C++ StringT怎么用?C++ StringT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenFile
void TextInputT::ReadGlobalElementMap (const StringT& name, iArrayT& elemmap)
{
ifstreamT geo;
OpenFile (geo, ".geo");
StringT s;
int numelms;
char line [255];
if (!AdvanceToBlock (geo, name, "Connectivities") ||
!geo.FindString ("Number of elements", s) ||
!s.Tail ('=', numelms)) throw ExceptionT::kDatabaseFail;
if (elemmap.Length() != numelms) throw ExceptionT::kSizeMismatch;
/* advance to the start of the connectivity block */
if (!geo.FindString("index", s)) throw ExceptionT::kDatabaseFail;
/* read map */
elemmap = 0;
for (int i=0; i < numelms; i++)
{
int index;
geo >> index >> elemmap[i];
geo.getline (line, 254);
}
}
示例2: GetIterationInfo
/* collect global and local iterations info for each time step */
void MRSSKStV::GetIterationInfo(bool get_iters, int loc_iters)
{
if(get_iters) {
/* write data */
const StringT& input_file = fSSMatSupport->InputFile();
/* output filenames */
StringT iterdata;
iterdata.Root(input_file);
iterdata.Append(".iterdata.", fSSMatSupport->StepNumber());
/* open output streams */
ofstreamT out_idata(iterdata);
/* write */
out_idata << "Time step number: " << setw(kIntWidth)
<< fSSMatSupport->StepNumber() << endl;
out_idata << "Global iteration number:" << setw(kIntWidth)
<< fSSMatSupport->GroupIterationNumber() << endl;
out_idata << "Number of local iterations to converge:" << setw(kIntWidth)
<< loc_iters << endl;
out_idata.close(); /* close */
} // if(get_iters)
}
示例3: if
void NodeManagerPrimitive::RegisterOutput (OutputBaseT& output, MakeCSE_IOManager& input)
{
// FUTURE: carry over node tags
fOutputNodeMap.Dimension (fCoordinates.MajorDim());
fOutputNodeMap.SetValueToPosition ();
fOutputNodeMap ++;
output.SetCoordinates (fCoordinates, &fOutputNodeMap);
sArrayT blocktonodesets;
input.BlockToNode (blocktonodesets);
int nsetid = 1;
for (int g=0; g < fNodeSetID.Length(); g++)
if (nsetid < atoi (fNodeSetID[g]))
nsetid = atoi (fNodeSetID[g]) + 1;
iArrayT nodes;
for (int i=0; i < blocktonodesets.Length(); i++)
{
StringT name;
name.Append (nsetid + 1);
out << "\n Creating Node Set from Element Group ID . . . . = "
<< blocktonodesets[i] << '\n';
theBoss->NodesUsed (blocktonodesets[i], nodes);
if (nodes.Length() > 0)
AddNodeSet (name, nodes, CSEConstants::kSplit);
else
out << "\n No nodes found...\n";
}
for (int n=0; n < fNodeSetData.Length(); n++)
output.AddNodeSet (fNodeSetData[n], fNodeSetID[n]);
}
示例4: read_s
void
read_s(
StringT& str,
void const* data,
std::size_t const size
) {
duct::IO::StreamContext ctx(FromU::id, duct::Endian::system);
duct::IO::imemstream stream(data, size * FromU::char_size);
std::printf(
"stream size: %lu\n",
static_cast<unsigned long>(duct::IO::size(stream))
);
DUCT_ASSERTE(stream.good());
ctx.read_string(
stream, str, static_cast<std::streamsize>(size), duct::CHAR_NULL
);
DUCT_ASSERTE(stream.good());
print_states(stream);
std::printf(
"String [size: %lu bsize: %lu len: %lu]: |",
static_cast<unsigned long>(size),
static_cast<unsigned long>(size*FromU::char_size),
static_cast<unsigned long>(str.size())
);
std::cout << str << "|\n";
str.clear();
}
示例5: FileName
/* generate database file name for the given ID */
void ExodusOutputT::FileName(int ID, StringT& filename) const
{
/* root */
filename = fOutroot;
/* tack on sequence number */
if (fSequence > 0) filename.Append(".sq", fSequence + 1);
/* group number */
//filename.Append(".gp", fElementSets[ID]->ID());
//NOTE: it's hard to resolve the number of element groups from the
// number of io groups based solely on what's in the database,
// so skip it for now.
/* I/O ID */
filename.Append(".io", ID);
/* changing geometry */
if (fElementSets[ID]->Changing())
filename.Append(".ps", fElementSets[ID]->PrintStep(), 4);
/* assuming no more than 1000 output steps */
/* extension */
filename.Append(".exo");
}
示例6:
/* operator support */
ifstreamT& PartitionT::Read(ifstreamT& in)
{
/* set comment marker */
char old_marker = in.comment_marker();
in.set_marker(CommentMarker());
/* check version */
StringT version;
in >> version;
if (version != sPartitionTVersion)
ExceptionT::BadInputValue("operator>>PartitionT",
"file version %s is not the current %s", version.Pointer(), sPartitionTVersion);
in >> fNumPartitions; // number of parts
in >> fID; // partition number
in >> fScope; // numbering scope
in >> fDecompType; // decomposition type
int length;
// read grid parameters for spatial decomposition
if (fDecompType == PartitionT::kSpatial) {
in >> length;
fGridDims.Dimension(length);
in >> fGridDims;
fGridPosition.Dimension(length);
in >> fGridPosition;
}
示例7: var
StringT ParaDynOutputT::CreateFileName (const StringT& Label) const
{
StringT var (fOutroot);
/* tack on extension */
var.Append (".");
var.Append (Label);
return var;
}
示例8: add_dir_sep
void add_dir_sep(StringT& str)
{
if (
str.IsEmpty() ||
(str[str.GetLength() - 1] != tdir_sep::value)
)
{
str += tdir_sep::value;
}
}
示例9: CompiledFunction
Value * Compiler::lookup (Symbol * identifier) {
StringT functionName = identifier->value();
llvm::Function* code = m_engine->FindFunctionNamed(functionName.c_str());
if (!code) {
return NULL;
}
return new CompiledFunction(code);
}
示例10: Save
void __stdcall BlackConfigurator::Save(const StringT& filename)
{
FILE* fp = NULL;
if (_tfopen_s(&fp, filename.c_str(), _T("wb+, ccs=UTF-8")) != 0) {
SXLOG_INF(g_local_logger) << _X(" open file for write failed! filepath:") << filename.c_str() << LBT << END;
return;
}
ConfItemDictFileWriter writer(this, fp, 0);
writer.Write();
fclose(fp);
}
示例11: generate_scalar_swap
void generate_scalar_swap(StringT & source, std::string const & numeric_string)
{
source.append("__kernel void swap( \n");
source.append(" __global "); source.append(numeric_string); source.append(" * s1, \n");
source.append(" __global "); source.append(numeric_string); source.append(" * s2) \n");
source.append("{ \n");
source.append(" "); source.append(numeric_string); source.append(" tmp = *s2; \n");
source.append(" *s2 = *s1; \n");
source.append(" *s1 = tmp; \n");
source.append("} \n");
}
示例12: unescape_string
StringT unescape_string (const StringT & value) {
StringStreamT buffer;
StringT::const_iterator i = value.begin(), end = value.end();
// Skip enclosing quotes
++i;
--end;
for (; i < end; ++i) {
if (*i == '\\') {
++i;
switch (*i) {
case 't':
buffer << '\t';
continue;
case 'r':
buffer << '\r';
continue;
case 'n':
buffer << '\n';
continue;
case '\\':
buffer << '\\';
continue;
case '"':
buffer << '"';
continue;
case '\'':
buffer << '\'';
continue;
case 'x':
if ((end - i) >= 2) {
StringT::value_type value = Math::convert_to_digit(*(++i)) << 4;
value |= Math::convert_to_digit(*(++i));
buffer << (StringT::value_type)value;
continue;
} else {
break;
}
case '.':
continue;
}
throw std::runtime_error("Could not parse string escape!");
} else {
buffer << *i;
}
}
return buffer.str();
}
示例13: parse_constant
Token parse_constant(StringIteratorT begin, StringIteratorT end, const StringT & constant) {
StringIteratorT s = begin;
StringIteratorT c = constant.begin();
while (s != end && c != constant.end() && *c == *s) s++, c++;
if (c == constant.end()) {
return Token(begin, s);
} else {
return Token();
}
}
示例14: Load
bool __stdcall BlackConfigurator::Load(const StringT& filename)
{
//Clear();
FILE* fp = NULL;
if (_tfopen_s(&fp, filename.c_str(), _T("rb+, ccs=UTF-8")) != 0) {
SXLOG_INF(g_local_logger) << _X(" open file for read failed! filepath:") << filename.c_str() << LBT << END;
return false;
}
ConfItemDictFileReader reader(fp);
ConfItemDict* result_dict = reader.Read();
return false;
}
示例15: file
bool TextInputT::OpenFile (ifstreamT& in, const char* ext) const
{
StringT file (fFileRoot);
file.Append (ext);
in.open (file);
if (!in.is_open())
{
fout << "\nTextInputT::OpenFile unable to open " << file << "\n\n";
return false;
}
return true;
}