text
stringlengths 0
2.2M
|
---|
return true;
|
currentXML.reset (newXML.release());
|
stopTimer();
|
resources.loadFromCpp (getCppFile(), cppContent);
|
bool result = loadFromXml (*currentXML);
|
extractCustomPaintSnippetsFromCppFile (cppContent);
|
return result;
|
}
|
void JucerDocument::refreshCustomCodeFromDocument()
|
{
|
const String cppContent (cpp->getCodeDocument().getAllContent());
|
extractCustomPaintSnippetsFromCppFile (cppContent);
|
}
|
void JucerDocument::extractCustomPaintSnippetsFromCppFile (const String& cppContent)
|
{
|
StringArray customPaintSnippets;
|
auto lines = StringArray::fromLines (cppContent);
|
int last = 0;
|
while (last >= 0)
|
{
|
const int start = indexOfLineStartingWith (lines, "//[UserPaintCustomArguments]", last);
|
if (start < 0)
|
break;
|
const int end = indexOfLineStartingWith (lines, "//[/UserPaintCustomArguments]", start);
|
if (end < 0)
|
break;
|
last = end + 1;
|
String result;
|
for (int i = start + 1; i < end; ++i)
|
result << lines [i] << newLine;
|
customPaintSnippets.add (CodeHelpers::unindent (result, 4));
|
}
|
applyCustomPaintSnippets (customPaintSnippets);
|
}
|
std::unique_ptr<XmlElement> JucerDocument::pullMetaDataFromCppFile (const String& cpp)
|
{
|
auto lines = StringArray::fromLines (cpp);
|
auto startLine = indexOfLineStartingWith (lines, "BEGIN_JUCER_METADATA", 0);
|
if (startLine > 0)
|
{
|
auto endLine = indexOfLineStartingWith (lines, "END_JUCER_METADATA", startLine);
|
if (endLine > startLine)
|
return parseXML (lines.joinIntoString ("\n", startLine + 1, endLine - startLine - 1));
|
}
|
return nullptr;
|
}
|
bool JucerDocument::isValidJucerCppFile (const File& f)
|
{
|
if (f.hasFileExtension (cppFileExtensions))
|
{
|
std::unique_ptr<XmlElement> xml (pullMetaDataFromCppFile (f.loadFileAsString()));
|
if (xml != nullptr)
|
return xml->hasTagName (jucerCompXmlTag);
|
}
|
return false;
|
}
|
static JucerDocument* createDocument (SourceCodeDocument* cpp)
|
{
|
auto& codeDoc = cpp->getCodeDocument();
|
std::unique_ptr<XmlElement> xml (JucerDocument::pullMetaDataFromCppFile (codeDoc.getAllContent()));
|
if (xml == nullptr || ! xml->hasTagName (JucerDocument::jucerCompXmlTag))
|
return nullptr;
|
const String docType (xml->getStringAttribute ("documentType"));
|
std::unique_ptr<JucerDocument> newDoc;
|
if (docType.equalsIgnoreCase ("Button"))
|
newDoc.reset (new ButtonDocument (cpp));
|
if (docType.equalsIgnoreCase ("Component") || docType.isEmpty())
|
newDoc.reset (new ComponentDocument (cpp));
|
if (newDoc != nullptr && newDoc->reloadFromDocument())
|
return newDoc.release();
|
return nullptr;
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.