本文整理汇总了C++中JString::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ JString::Print方法的具体用法?C++ JString::Print怎么用?C++ JString::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JString
的用法示例。
在下文中一共展示了JString::Print方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GFGGetPrefsManager
void
GFGClass::WriteFunction
(
ostream& os,
GFGMemberFunction* fn,
const JBoolean interface
)
{
if (interface)
{
fn->GetInterface().Print(os);
os << endl;
return;
}
JString access = "public";
if (fn->IsProtected())
{
access = "protected";
}
JString s = GFGGetPrefsManager()->GetFunctionComment(fn->GetFnName(), access);
s.Print(os);
fn->GetReturnType().Print(os);
os << endl;
itsClassName.Print(os);
os << "::";
fn->GetFnName().Print(os);
const JSize count = fn->GetArgCount();
if (count == 0)
{
os << "()" << endl;
}
else
{
os << "\n\t(\n";
for (JIndex i = 1; i <= count; i++)
{
JString arg = fn->GetArg(i);
os << "\t";
arg.Print(os);
if (i != count)
{
os << ",";
}
os << endl;
}
os << "\t)" << endl;
}
if (fn->IsConst())
{
os << "\tconst" << endl;
}
os << "{\n\n}" << endl << endl;
}
示例2: pageStr
void
CBPTPrinter::PrintHeader
(
ostream& output,
const JIndex pageIndex
)
{
if (itsPrintHeaderFlag)
{
const JString dateStr = JGetTimeStamp();
JString pageStr(pageIndex, 0);
pageStr.Prepend("Page ");
itsHeaderName.Print(output);
output << '\n';
dateStr.Print(output);
const JInteger spaceCount =
GetPageWidth() - dateStr.GetLength() - pageStr.GetLength();
for (JInteger i=1; i<=spaceCount; i++)
{
output << ' ';
}
pageStr.Print(output);
output << "\n\n\n";
}
}
示例3: output
JBoolean
JConvertToStream
(
const int input,
ifstream* input2,
JString* tempFullName,
const JBoolean closeInput
)
{
JString data;
if (!JReadAll(input, &data, closeInput))
{
return kJFalse;
}
if (!(JCreateTempFile(tempFullName)).OK())
{
return kJFalse;
}
ofstream output(*tempFullName);
data.Print(output);
output.close();
input2->open(*tempFullName);
return JI2B(input2->good());
}
示例4: output
void
JUpdateCVSIgnore
(
const JCharacter* ignoreFullName
)
{
JString path, name;
JSplitPathAndName(ignoreFullName, &path, &name);
const JString cvsFile = JCombinePathAndName(path, ".cvsignore");
if (!JFileExists(cvsFile) && JGetVCSType(path) != kJCVSType)
{
return;
}
JString cvsData;
JReadFile(cvsFile, &cvsData);
if (!cvsData.IsEmpty() && !cvsData.EndsWith("\n"))
{
cvsData += "\n";
}
name += "\n";
if (!cvsData.Contains(name))
{
JEditVCS(cvsFile);
cvsData += name;
ofstream output(cvsFile);
cvsData.Print(output);
}
}
示例5: os
void
GMMIMEParser::WriteAttachment
(
const JString& data,
const GMIMEHeader& header
)
{
JString filename = header.GetFileName();
if (filename.IsEmpty())
{
const JError err = JCreateTempFile(itsAttachDir, NULL, &filename);
if (!err.OK())
{
err.ReportIfError();
return;
}
}
else
{
filename = JCombinePathAndName(itsAttachDir, filename);
}
AdjustAttachmentName(header, &filename);
std::ofstream os(filename);
if (header.GetEncoding() == kBase64Encoding)
{
std::istrstream is(data.GetCString(), data.GetLength());
JDecodeBase64(is, os);
}
else
{
data.Print(os);
}
}
示例6: frame
void
GenerateCode
(
istream& input,
ostream& output,
const JString& stringPath,
const JString& formName,
const JString& tagName,
const JString& userTopEnclVarName,
JPtrArray<JString>* objTypes,
JPtrArray<JString>* objNames
)
{
JIndex i;
// width
input >> ws;
JString line = JReadUntilws(input);
assert( line == kFormWidthMarker );
JSize formWidth;
input >> formWidth;
// height
input >> ws;
line = JReadUntilws(input);
assert( line == kFormHeightMarker );
JSize formHeight;
input >> formHeight;
// object count (marker contains whitespace)
input >> ws;
line = JReadUntil(input, ':') + ":";
assert( line == kFormObjCountMarker );
JSize itemCount;
input >> itemCount;
// create window
const JString topEnclFrameName = tagName + "_Frame";
const JString topEnclApName = tagName + "_Aperture";
JString topEnclVarName;
if (tagName == kDefaultDelimTag)
{
topEnclVarName = kDefTopEnclVarName;
output << " JXWindow* window = new JXWindow(this, ";
output << formWidth << ',' << formHeight;
output << ", \"\");" << endl;
output << " assert( window != NULL );" << endl;
output << endl;
}
else
{
assert( !userTopEnclVarName.IsEmpty() );
topEnclVarName = userTopEnclVarName;
output << " const JRect ";
topEnclFrameName.Print(output);
output << " = ";
topEnclVarName.Print(output);
output << "->GetFrame();" << endl;
output << " const JRect ";
topEnclApName.Print(output);
output << " = ";
topEnclVarName.Print(output);
output << "->GetAperture();" << endl;
output << " ";
topEnclVarName.Print(output);
output << "->AdjustSize(" << formWidth << " - ";
topEnclApName.Print(output);
output << ".width(), " << formHeight << " - ";
topEnclApName.Print(output);
output << ".height());" << endl;
output << endl;
}
// We need to calculate the enclosure for each object. Since objects
// are drawn in the order added, an object must come after its enclosure
// in the list in order to be visible.
JArray<JRect> rectList(10);
JArray<JBoolean> isInstanceVar(10);
// This array is used to send the options to ApplyOptions.
// It does not own the pointers that it contains.
JPtrArray<JString> optionValues(JPtrArrayT::kForgetAll, kOptionCount);
for (i=1; i<=kOptionCount; i++)
{
optionValues.Append(NULL);
}
// generate code for each object
//.........这里部分代码省略.........
示例7: optionMap
void
ApplyOptions
(
ostream& output,
const JString& className,
const JString& formName,
const JString& tagName,
const JString& varName,
const JPtrArray<JString>& values,
const JString& flSize,
const JString& flStyle,
const JString& flColor,
JStringManager* stringMgr
)
{
ifstream optionMap(optionMapFile);
optionMap >> ws;
while (1)
{
if (optionMap.peek() == '#')
{
JIgnoreLine(optionMap);
}
else
{
const JString aClassName = JReadUntilws(optionMap);
if (optionMap.eof() || optionMap.fail())
{
break;
}
else if (aClassName != className)
{
for (JIndex i=1; i<=kOptionCount; i++)
{
JIgnoreLine(optionMap);
}
}
else
{
JIndex i;
JBoolean supported;
// shortcuts
optionMap >> ws >> supported;
if (supported)
{
optionMap >> ws;
const JString function = JReadUntilws(optionMap);
const JString* value = values.NthElement(kShortcutsIndex);
if (!value->IsEmpty())
{
JString id = varName;
id += "::";
id += formName;
id += "::shortcuts::";
id += tagName; // last since it is almost always the same
output << " ";
varName.Print(output);
output << "->";
function.Print(output);
output << "(JGetString(\"";
id.Print(output);
output << "\"));" << endl;
JString* s = new JString(*value);
assert( s != NULL );
stringMgr->SetElement(id, s, JPtrArrayT::kDelete);
}
}
else
{
JIgnoreLine(optionMap);
}
// colors
for (i=2; i<=kOptionCount; i++)
{
optionMap >> ws >> supported;
if (supported)
{
optionMap >> ws;
const JString defValue = JReadUntilws(optionMap);
const JString function = JReadUntilws(optionMap);
const JString* value = values.NthElement(i);
if (*value != defValue)
{
JString jxColor;
if (ConvertXFormsColor(*value, &jxColor))
{
output << " ";
varName.Print(output);
output << "->";
function.Print(output);
output << '(';
jxColor.Print(output);
output << ");" << endl;
}
//.........这里部分代码省略.........
示例8: if
int
main
(
int argc,
char* argv[]
)
{
// parse the command line options
JPtrArray<JString> inputFileList(JPtrArrayT::kDeleteAll);
JString dataVarName, outputFileName, databaseFileName;
JBoolean debug;
GetOptions(argc, argv, &inputFileList,
&dataVarName, &outputFileName, &databaseFileName, &debug);
const JSize inputCount = inputFileList.GetElementCount();
// check mod times of input files
/*
This doesn't work because compiling different versions of the program
requires different sets of string files, none of which may have been
modified in a long time. The output file still needs to be re-built,
however!
time_t outputTime;
if ((JGetModificationTime(outputFileName, &outputTime)).OK())
{
JBoolean changed = kJFalse;
for (JIndex i=1; i<=inputCount; i++)
{
const JString* inputFileName = inputFileList.NthElement(i);
time_t t;
if (!(JGetModificationTime(*inputFileName, &t)).OK())
{
cerr << argv[0] << ": " << *inputFileName << " does not exist" << endl;
return 1;
}
else if (t >= outputTime)
{
changed = kJTrue;
break;
}
}
if (!changed)
{
return 0;
}
}
*/
// process the input files
JStringManager mgr;
for (JIndex i=1; i<=inputCount; i++)
{
const JString* inputFileName = inputFileList.NthElement(i);
if (JDirectoryExists(*inputFileName))
{
continue;
}
ifstream input(*inputFileName);
if (!input.good())
{
cerr << argv[0] << ": unable to open " << *inputFileName << endl;
return 1;
}
mgr.MergeFile(input, debug);
if (input.fail())
{
cerr << argv[0] << ": error while reading " << *inputFileName << endl;
return 1;
}
}
// generate the output file
std::ostringstream data1;
mgr.WriteFile(data1);
JString data1Str = data1.str();
if (!databaseFileName.IsEmpty())
{
ofstream dbOutput(databaseFileName);
data1Str.Print(dbOutput);
}
if (!outputFileName.IsEmpty())
{
JIndex i = 1;
while (data1Str.LocateNextSubstring("\\", &i))
{
data1Str.ReplaceSubstring(i,i, "\\\\");
i += 2;
}
i = 1;
while (data1Str.LocateNextSubstring("\"", &i))
{
//.........这里部分代码省略.........
示例9: lastLineIndexStr
JBoolean
JPTPrinter::Print
(
const JCharacter* text,
ostream& trueOutput
)
{
ostream* dataOutput = &trueOutput;
ofstream* tempOutput = NULL;
JString tempName;
if (itsPrintReverseOrderFlag)
{
if (!(JCreateTempFile(&tempName)).OK())
{
return kJFalse;
}
tempOutput = new ofstream(tempName);
assert( tempOutput != NULL );
if (tempOutput->bad())
{
delete tempOutput;
JRemoveFile(tempName);
return kJFalse;
}
dataOutput = tempOutput;
}
const JSize headerLineCount = GetHeaderLineCount();
const JSize footerLineCount = GetFooterLineCount();
assert( itsPageHeight > headerLineCount + footerLineCount );
const JSize lineCountPerPage = itsPageHeight - headerLineCount - footerLineCount;
JLatentPG pg;
pg.VariableLengthProcessBeginning("Printing page...", kJTrue, kJFalse);
JBoolean keepGoing = kJTrue;
JUnsignedOffset i = 0;
JIndex pageIndex = 0;
JSize printCount = 0;
JSize textLineCount = 0;
while (keepGoing && text[i] != '\0')
{
pageIndex++;
const JBoolean shouldPrintPage =
JI2B(itsFirstPageIndex <= pageIndex &&
(itsLastPageIndex == 0 || pageIndex <= itsLastPageIndex));
std::ostringstream bitBucket;
ostream* output = shouldPrintPage ? dataOutput : (&bitBucket);
if (shouldPrintPage)
{
printCount++;
if (printCount > 1)
{
*output << kPageSeparatorStr;
}
}
if (headerLineCount > 0)
{
PrintHeader(*output, pageIndex);
}
JSize lineNumberWidth = 0;
if (itsPrintLineNumberFlag)
{
const JString lastLineIndexStr(pageIndex * lineCountPerPage, 0);
lineNumberWidth = lastLineIndexStr.GetLength();
}
JSize lineCount = 0;
while (lineCount < lineCountPerPage && text[i] != '\0')
{
JSize col = 0;
if (itsPrintLineNumberFlag)
{
const JString lineNumberStr(textLineCount+1, 0);
const JSize spaceCount = lineNumberWidth - lineNumberStr.GetLength();
for (JIndex j=1; j<=spaceCount; j++)
{
*output << ' ';
}
lineNumberStr.Print(*output);
*output << kLineNumberMarginStr;
col += lineNumberWidth + kLineNumberMarginWidth;
}
if (col >= itsPageWidth) // insures progress, even in ludicrous boundary case
{
col = itsPageWidth - 1;
}
while (col < itsPageWidth && text[i] != '\n' && text[i] != '\0')
{
if (text[i] == '\t')
//.........这里部分代码省略.........