Example #1
0
  static bool canFileBeReincluded (File const& f)
  {
    String content (f.loadFileAsString());

    for (;;)
    {
      content = content.trimStart();

      if (content.startsWith ("//"))
        content = content.fromFirstOccurrenceOf ("\n", false, false);
      else if (content.startsWith ("/*"))
        content = content.fromFirstOccurrenceOf ("*/", false, false);
      else
        break;
    }

    StringArray lines;
    lines.addLines (content);
    lines.trim();
    lines.removeEmptyStrings();

    const String l1 (lines[0].removeCharacters (" \t").trim());
    const String l2 (lines[1].removeCharacters (" \t").trim());

    bool result;
    if (l1.replace ("#ifndef", "#define") == l2)
      result = false;
    else
      result = true;

    return result;
  }
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
void CtrlrLuaMethodEditArea::mouseDoubleClick (const MouseEvent &e)
{
	// LUA compile error: ERROR: [string "function myNewMethod()..."]:4: '=' expected near 'end'
	// Search result: SEARCH: [method]:3 position:43-46

	const String line = output->getLineAtPosition (output->getTextIndexAt (e.x, e.y)).trim();

	//_DBG(line);

	if (line.startsWithIgnoreCase("ERROR"))
	{
		const int errorInLine = line.fromFirstOccurrenceOf ("]:", false, true).getIntValue();

		if (errorInLine > 0 && owner.getCurrentEditor())
		{
			owner.getCurrentEditor()->setErrorLine(errorInLine);
		}
	}
	else if (line.startsWithIgnoreCase("Method: "))
	{
		const String methodName	= line.fromFirstOccurrenceOf ("Method: ", false, false).upToFirstOccurrenceOf("line: ", false, true).trim();
		const int errorInLine	= line.fromFirstOccurrenceOf ("line: ", false, true).getIntValue();
		const int positionStart	= line.fromFirstOccurrenceOf ("start: ", false,true).getIntValue();
		const int positionEnd	= line.fromFirstOccurrenceOf ("end: ", false,true).getIntValue();

		owner.searchResultClicked (methodName, errorInLine, positionStart, positionEnd);
	}
}
void JucerDocument::setParentClasses (const String& classes)
{
    if (classes != parentClasses)
    {
        StringArray parentClassLines (getCleanedStringArray (StringArray::fromTokens (classes, ",", StringRef())));

        for (int i = parentClassLines.size(); --i >= 0;)
        {
            String s (parentClassLines[i]);
            String type;

            if (s.startsWith ("public ")
                || s.startsWith ("protected ")
                || s.startsWith ("private "))
            {
                type = s.upToFirstOccurrenceOf (" ", true, false);
                s = s.fromFirstOccurrenceOf (" ", false, false);

                if (s.trim().isEmpty())
                    type = s = String::empty;
            }

            s = type + CodeHelpers::makeValidIdentifier (s.trim(), false, false, true);

            parentClassLines.set (i, s);
        }

        parentClasses = parentClassLines.joinIntoString (", ");
        changed();
    }
}
Example #4
0
    void paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected) override
    {
        if (rowIsSelected)
            g.fillAll (Colours::deepskyblue);

        if (JuceDemoTypeBase* type = JuceDemoTypeBase::getDemoTypeList() [rowNumber])
        {
            String name (type->name.trimCharactersAtStart ("0123456789").trimStart());

            AttributedString a;
            a.setJustification (Justification::centredLeft);

            String category;

            if (name.containsChar (':'))
            {
                category = name.upToFirstOccurrenceOf (":", true, false);
                name = name.fromFirstOccurrenceOf (":", false, false).trim();

                if (height > 20)
                    category << "\n";
                else
                    category << " ";
            }

            if (category.isNotEmpty())
                a.append (category, Font (10.0f), Colour::greyLevel (0.5f));

            a.append (name, Font (13.0f), Colours::white.withAlpha (0.9f));

            a.draw (g, Rectangle<int> (width + 10, height).reduced (6, 0).toFloat());
        }
    }
void XmlDocument::skipHeader()
{
    const int headerStart = input.indexOf (CharPointer_UTF8 ("<?xml"));

    if (headerStart >= 0)
    {
        const int headerEnd = (input + headerStart).indexOf (CharPointer_UTF8 ("?>"));
        if (headerEnd < 0)
            return;

       #if JUCE_DEBUG
        const String header (input + headerStart, (size_t) (headerEnd - headerStart));
        const String encoding (header.fromFirstOccurrenceOf ("encoding", false, true)
                                     .fromFirstOccurrenceOf ("=", false, false)
                                     .fromFirstOccurrenceOf ("\"", false, false)
                                     .upToFirstOccurrenceOf ("\"", false, false).trim());

        /* If you load an XML document with a non-UTF encoding type, it may have been
           loaded wrongly.. Since all the files are read via the normal juce file streams,
           they're treated as UTF-8, so by the time it gets to the parser, the encoding will
           have been lost. Best plan is to stick to utf-8 or if you have specific files to
           read, use your own code to convert them to a unicode String, and pass that to the
           XML parser.
        */
        jassert (encoding.isEmpty() || encoding.startsWithIgnoreCase ("utf-"));
       #endif

        input += headerEnd + 2;
    }

    skipNextWhiteSpace();

    const int docTypeIndex = input.indexOf (CharPointer_UTF8 ("<!DOCTYPE"));
    if (docTypeIndex < 0)
        return;

    input += docTypeIndex + 9;
    const String::CharPointerType docType (input);

    int n = 1;

    while (n > 0)
    {
        const juce_wchar c = readNextChar();

        if (outOfData)
            return;

        if (c == '<')
            ++n;
        else if (c == '>')
            --n;
    }

    dtdText = String (docType, (size_t) (input.getAddress() - (docType.getAddress() + 1))).trim();
}
Example #6
0
 /** this will validate denyLock message for server
     @param[in]  message                 message string
     @param[out] clientName              Name of client to show over tooltip of locked button
     @return     bool                    true if denyLock message */
 bool isServerIsLockedMessage(const String & message, String & clientName)
 {
     if(message.contains(serverIsLockedID))
     {
         clientName = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #7
0
 /** this will validate playAfterPause message
     @param[in]  message         message string
     @param[in]  index           Song's index that will be played
     @return     bool            true if playAfterPause message */
 bool isPlayAfterPauseMessage(const String & message, String & index)
 {
     if(message.contains(playAfterPauseMessageID))
     {
         index = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #8
0
 /** this will validate playAfterStop message
     @param[in]  message         message string
     @param[in]  indexList       No of rows that are delete from mediaArray
     @return     bool            true if playAfterStop message */
 bool isDeleteInPlayList(const String & message, Array<int> & indexList)
 {
     String tempMessage = message;
     if(tempMessage.contains(deleteInPlayListID))
     {
         // SOme logic needed here to convert String to Array
         tempMessage = tempMessage.fromFirstOccurrenceOf(messageSeparator, false, false);
         String index;
         while(tempMessage != "")
         {
             index = tempMessage.upToFirstOccurrenceOf(messageSeparator, false, false);
             tempMessage = tempMessage.fromFirstOccurrenceOf(messageSeparator, false, false);
             indexList.add(index.getIntValue());
         }
         return true;
     }
     else
         return false;
 }
Example #9
0
 /** this will validate playAfterStop message
     @param[in]  message         message string
     @param[in]  playList        PlayList as xmlElement
     @return     bool            true if playAfterStop message */
 bool isAddInPlayList(const String & message, String & playList)
 {
     if(message.contains(addInPlayListID))
     {
         playList = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #10
0
 /** this will validate client's no access message
     @param[in]  message         message string
     @param[in]  errorMessage    errorMessage string
     @return     bool            true if client has no access message*/
 bool isNoAccessMessage(const String & message, String & errorMessage)
 {
     if(message.contains(noAccessMessageID))
     {
         errorMessage = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #11
0
 /** this will validate connection time client name
     @param[in]  message     message string
     @param[in]  name        name string
     @return     bool        true if connection time client name is valid */
 bool isConnectTimeName(const String & message, String & name)
 {
     if(message.contains(connectTimeNameID))
     {
         name = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #12
0
 /** this will validate playlist message for server
     @param[in]  message                 message string
     @param[in]  playListInString        playListInString string
     @return     bool                    true if playList message is valid */
 bool isPlayListMessage(const String & message, String & playListInString)
 {
     if(message.contains(playListMessageID))
     {
         playListInString = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #13
0
//==============================================================================
KeyPress KeyPress::createFromDescription (const String& desc)
{
    int modifiers = 0;

    for (int i = 0; i < numElementsInArray (KeyPressHelpers::modifierNames); ++i)
        if (desc.containsWholeWordIgnoreCase (KeyPressHelpers::modifierNames[i].name))
            modifiers |= KeyPressHelpers::modifierNames[i].flag;

    int key = 0;

    for (int i = 0; i < numElementsInArray (KeyPressHelpers::translations); ++i)
    {
        if (desc.containsWholeWordIgnoreCase (String (KeyPressHelpers::translations[i].name)))
        {
            key = KeyPressHelpers::translations[i].code;
            break;
        }
    }

    if (key == 0)
        key = KeyPressHelpers::getNumpadKeyCode (desc);

    if (key == 0)
    {
        // see if it's a function key..
        if (! desc.containsChar ('#')) // avoid mistaking hex-codes like "#f1"
        {
            for (int i = 1; i <= 35; ++i)
            {
                if (desc.containsWholeWordIgnoreCase ("f" + String (i)))
                {
                    if (i <= 16)        key = F1Key + i - 1;
                    else if (i <= 24)   key = F17Key + i - 17;
                    else if (i <= 35)   key = F25Key + i - 25;
                }
            }
        }

        if (key == 0)
        {
            // give up and use the hex code..
            auto hexCode = desc.fromFirstOccurrenceOf ("#", false, false)
                               .retainCharacters ("0123456789abcdefABCDEF")
                               .getHexValue32();

            if (hexCode > 0)
                key = hexCode;
            else
                key = (int) CharacterFunctions::toUpperCase (desc.getLastCharacter());
        }
    }

    return KeyPress (key, ModifierKeys (modifiers), 0);
}
Example #14
0
 /** this will validate playlist message for server
     @param[in]  message                 message string
     @param[out] dragPlayListInString	dragPlayListInString string
 	@param[out] dropPlayListInString	dropPlayListInString string
     @return     bool                    true if playList message is valid */
 bool isdragDropPlayListMessage(const String & message, String & dragPlayListInString, String & dropPlayListInString)
 {
     if(message.contains(dragDropInPlayListID))
     {
         dragPlayListInString = message.fromFirstOccurrenceOf (messageSeparator, false, false);
         dragPlayListInString = dragPlayListInString.upToFirstOccurrenceOf (messageSeparator, false, false);
         dropPlayListInString = message.fromLastOccurrenceOf (messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #15
0
RSAKey::RSAKey (const String& s)
{
    if (s.containsChar (','))
    {
        part1.parseString (s.upToFirstOccurrenceOf (",", false, false), 16);
        part2.parseString (s.fromFirstOccurrenceOf (",", false, false), 16);
    }
    else
    {
        // the string needs to be two hex numbers, comma-separated..
        jassertfalse;
    }
}
Example #16
0
 /** this will validate playAfterStop message
     @param[in]  message         message string
     @param[in]  playList        PlayList as xmlElement
     @return     bool            true if playAfterStop message */
 bool isDropInPlayList(const String & message, String & playList, String & insertionIndex)
 {
     String tempString;
     if(message.contains(dropInPlayListID))
     {
         tempString = message.fromFirstOccurrenceOf(messageSeparator, false, false);
         playList = tempString.upToFirstOccurrenceOf (messageSeparator, false, false);
         insertionIndex = tempString.fromLastOccurrenceOf (messageSeparator, false, false);
         return true;
     }
     else
         return false;
 }
Example #17
0
Font Font::fromString (const String& fontDescription)
{
    const int separator = fontDescription.indexOfChar (';');
    String name;

    if (separator > 0)
        name = fontDescription.substring (0, separator).trim();

    if (name.isEmpty())
        name = getDefaultSansSerifFontName();

    String sizeAndStyle (fontDescription.substring (separator + 1).trimStart());

    float height = sizeAndStyle.getFloatValue();
    if (height <= 0)
        height = 10.0f;

    const String style (sizeAndStyle.fromFirstOccurrenceOf (" ", false, false));

    return Font (name, style, height);
}
bool ChildProcessSlave::initialiseFromCommandLine (const String& commandLine,
                                                   const String& commandLineUniqueID,
                                                   int timeoutMs)
{
    auto prefix = getCommandLinePrefix (commandLineUniqueID);

    if (commandLine.trim().startsWith (prefix))
    {
        auto pipeName = commandLine.fromFirstOccurrenceOf (prefix, false, false)
                                   .upToFirstOccurrenceOf (" ", false, false).trim();

        if (pipeName.isNotEmpty())
        {
            connection.reset (new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs));

            if (! connection->isConnected())
                connection.reset();
        }
    }

    return connection != nullptr;
}
Example #19
0
void LibraryModule::getConfigFlags (Project& project, OwnedArray<Project::ConfigFlag>& flags) const
{
    const File header (getModuleHeaderFile (moduleInfo.getFolder()));
    jassert (header.exists());

    StringArray lines;
    header.readLines (lines);

    for (int i = 0; i < lines.size(); ++i)
    {
        String line (lines[i].trim());

        if (line.startsWith ("/**") && line.containsIgnoreCase ("Config:"))
        {
            ScopedPointer <Project::ConfigFlag> config (new Project::ConfigFlag());
            config->sourceModuleID = getID();
            config->symbol = line.fromFirstOccurrenceOf (":", false, false).trim();

            if (config->symbol.length() > 2)
            {
                ++i;

                while (! (lines[i].contains ("*/") || lines[i].contains ("@see")))
                {
                    if (lines[i].trim().isNotEmpty())
                        config->description = config->description.trim() + " " + lines[i].trim();

                    ++i;
                }

                config->description = config->description.upToFirstOccurrenceOf ("*/", false, false);
                config->value.referTo (project.getConfigFlag (config->symbol));
                flags.add (config.release());
            }
        }
    }
}
Example #20
0
  void findAllFilesIncludedIn (const File& hppTemplate, StringArray& alreadyIncludedFiles)
  {
    StringArray lines;
    lines.addLines (hppTemplate.loadFileAsString());

    for (int i = 0; i < lines.size(); ++i)
    {
      String line (lines[i]);

      if (line.removeCharacters (" \t").startsWithIgnoreCase ("#include\""))
      {
        const String filename (line.fromFirstOccurrenceOf ("\"", false, false)
          .upToLastOccurrenceOf ("\"", false, false));
        const File targetFile (findInclude (hppTemplate, filename));

        if (! alreadyIncludedFiles.contains (targetFile.getFullPathName()))
        {
          alreadyIncludedFiles.add (targetFile.getFullPathName());

          findAllFilesIncludedIn (targetFile, alreadyIncludedFiles);
        }
      }
    }
  }
Example #21
0
//==============================================================================
String File::parseAbsolutePath (const String& p)
{
    if (p.isEmpty())
        return String::empty;

#if JUCE_WINDOWS
    // Windows..
    String path (p.replaceCharacter ('/', '\\'));

    if (path.startsWithChar (separator))
    {
        if (path[1] != separator)
        {
            /*  When you supply a raw string to the File object constructor, it must be an absolute path.
                If you're trying to parse a string that may be either a relative path or an absolute path,
                you MUST provide a context against which the partial path can be evaluated - you can do
                this by simply using File::getChildFile() instead of the File constructor. E.g. saying
                "File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
                path if that's what was supplied, or would evaluate a partial path relative to the CWD.
            */
            jassertfalse;

            path = File::getCurrentWorkingDirectory().getFullPathName().substring (0, 2) + path;
        }
    }
    else if (! path.containsChar (':'))
    {
        /*  When you supply a raw string to the File object constructor, it must be an absolute path.
            If you're trying to parse a string that may be either a relative path or an absolute path,
            you MUST provide a context against which the partial path can be evaluated - you can do
            this by simply using File::getChildFile() instead of the File constructor. E.g. saying
            "File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
            path if that's what was supplied, or would evaluate a partial path relative to the CWD.
        */
        jassertfalse;

        return File::getCurrentWorkingDirectory().getChildFile (path).getFullPathName();
    }
#else
    // Mac or Linux..

    // Yes, I know it's legal for a unix pathname to contain a backslash, but this assertion is here
    // to catch anyone who's trying to run code that was written on Windows with hard-coded path names.
    // If that's why you've ended up here, use File::getChildFile() to build your paths instead.
    jassert ((! p.containsChar ('\\')) || (p.indexOfChar ('/') >= 0 && p.indexOfChar ('/') < p.indexOfChar ('\\')));

    String path (p);

    if (path.startsWithChar ('~'))
    {
        if (path[1] == separator || path[1] == 0)
        {
            // expand a name of the form "~/abc"
            path = File::getSpecialLocation (File::userHomeDirectory).getFullPathName()
                    + path.substring (1);
        }
        else
        {
            // expand a name of type "~dave/abc"
            const String userName (path.substring (1).upToFirstOccurrenceOf ("/", false, false));

            if (struct passwd* const pw = getpwnam (userName.toUTF8()))
                path = addTrailingSeparator (pw->pw_dir) + path.fromFirstOccurrenceOf ("/", false, false);
        }
    }
    else if (! path.startsWithChar (separator))
    {
       #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS
        if (! (path.startsWith ("./") || path.startsWith ("../")))
        {
            /*  When you supply a raw string to the File object constructor, it must be an absolute path.
                If you're trying to parse a string that may be either a relative path or an absolute path,
                you MUST provide a context against which the partial path can be evaluated - you can do
                this by simply using File::getChildFile() instead of the File constructor. E.g. saying
                "File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
                path if that's what was supplied, or would evaluate a partial path relative to the CWD.
            */
            jassertfalse;

           #if JUCE_LOG_ASSERTIONS
            Logger::writeToLog ("Illegal absolute path: " + path);
           #endif
        }
       #endif

        return File::getCurrentWorkingDirectory().getChildFile (path).getFullPathName();
    }
#endif

    while (path.endsWithChar (separator) && path != separatorString) // careful not to turn a single "/" into an empty string.
        path = path.dropLastCharacters (1);

    return path;
}
Example #22
0
//==============================================================================
int main (int argc, char* argv[])
{
  bool error = false;
  bool usage = true;

  const String name (argv[0]);

  Amalgamator amalgamator (name);
  bool gotCheckSystem = false;
  bool gotWildcards = false;
  bool gotTemplate = false;
  bool gotTarget = false;

  for (int i = 1; i < argc; ++i)
  {
    String option (argv[i]);

    String value;
    if (i + 1 < argc)
      value = String (argv[i+1]).unquoted ();

    if (option.compareIgnoreCase ("-i") == 0)
    {
      ++i;
      if (i < argc)
      {
        amalgamator.addDirectoryToSearch (value);
      }
      else
      {
        std::cout << name << ": Missing parameter for -i\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-f") == 0)
    {
      ++i;
      if (i < argc)
      {
        amalgamator.addForceReinclude (value);
      }
      else
      {
        std::cout << name << ": Missing parameter for -f\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-p") == 0)
    {
      ++i;
      if (i < argc)
      {
        amalgamator.addPreventReinclude (value);
      }
      else
      {
        std::cout << name << ": Missing parameter for -p\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-d") == 0)
    {
      ++i;
      if (i < argc)
      {
        if (value.contains ("="))
        {
          String name = value.upToFirstOccurrenceOf ("=", false, false);
          String define = value.fromFirstOccurrenceOf ("=", false, false);

          amalgamator.addDefine (name, define);
        }
        else
        {
          std::cout << name << ": Incorrect syntax for -d\n";
        }
      }
      else
      {
        std::cout << name << ": Missing parameter for -d\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-w") == 0)
    {
      ++i;
      if (i < argc)
      {
        if (!gotWildcards)
        {
          amalgamator.setWildcards (value);
        }
        else
        {
          std::cout << name << ": Duplicate option -w\n";
          error = true;
          break;
        }
      }
      else
      {
        std::cout << name << ": Missing parameter for -w\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-s") == 0)
    {
      if (!gotCheckSystem)
      {
        amalgamator.setCheckSystemIncludes (true);
        gotCheckSystem = true;
      }
      else
      {
        std::cout << name << ": Duplicate option -w\n";
        error = true;
        break;
      }
    }
    else if (option.compareIgnoreCase ("-v") == 0)
    {
      amalgamator.setVerbose ();
    }
    else if (option.startsWith ("-"))
    {
      std::cout << name << ": Unknown option \"" << option << "\"\n";
      error = true;
      break;
    }
    else
    {
      if (!gotTemplate)
      {
        amalgamator.setTemplate (option);
        gotTemplate = true;
      }
      else if (!gotTarget)
      {
        amalgamator.setTarget (option);
        gotTarget = true;
      }
      else
      {
        std::cout << name << ": Too many arguments\n";
        error = true;
        break;
      }
    }
  }

  if (gotTemplate && gotTarget)
  {
    usage = false;

    //amalgamator.print ();
    error = amalgamator.process ();
  }
  else
  {
    if (argc > 1)
      std::cout << name << " Too few arguments\n";

    error = true;
  }

  if (error && usage)
  {
    std::cout << "\n";
    std::cout << "  NAME" << "\n";
    std::cout << "  " << "\n";
    std::cout << "   " << name << " - produce an amalgamation of C/C++ source files." << "\n";
    std::cout << "  " << "\n";
    std::cout << "  SYNOPSIS" << "\n";
    std::cout << "  " << "\n";
    std::cout << "   " << name << " [-s]" << "\n";
    std::cout << "     [-w {wildcards}]" << "\n";
    std::cout << "     [-f {file|macro}]..." << "\n";
    std::cout << "     [-p {file|macro}]..." << "\n";
    std::cout << "     [-d {name}={file}]..." << "\n";
    std::cout << "     [-i {dir}]..." << "\n";
    std::cout << "     {inputFile} {outputFile}" << "\n";
    std::cout << "  " << "\n";
    std::cout << "  DESCRIPTION" << "\n";
    std::cout << "  " << "\n";
    std::cout << "   Produces an amalgamation of {inputFile} by replacing #include statements with" << "\n";
    std::cout << "   the contents of the file they refer to. This replacement will only occur if" << "\n";
    std::cout << "   the file was located in the same directory, or one of the additional include" << "\n";
    std::cout << "   paths added with the -i option." << "\n";
    std::cout << "   " << "\n";
    std::cout << "   Files included in angle brackets (system includes) are only inlined if the" << "\n";
    std::cout << "   -s option is specified." << "\n";
    std::cout << "  " << "\n";
    std::cout << "   If an #include line contains a macro instead of a string literal, the list" << "\n";
    std::cout << "   of definitions provided through the -d option is consulted to convert the" << "\n";
    std::cout << "   macro into a string." << "\n";
    std::cout << "  " << "\n";
    std::cout << "   A file will only be inlined once, with subsequent #include lines for the same" << "\n";
    std::cout << "   file silently ignored, unless the -f option is specified for the file." << "\n";
    std::cout << "  " << "\n";
    std::cout << "  OPTIONS" << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -s                Process #include lines containing angle brackets (i.e." << "\n";
    std::cout << "                      system includes). Normally these are not inlined." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -w {wildcards}    Specify a comma separated list of file name patterns to" << "\n";
    std::cout << "                      match when deciding to inline (assuming the file can be" << "\n";
    std::cout << "                      located). The default setting is \"*.cpp;*.c;*.h;*.mm;*.m\"." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -f {file|macro}   Force reinclusion of the specified file or macro on" << "\n";
    std::cout << "                      all appearances in #include lines." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -p {file|macro}   Prevent reinclusion of the specified file or macro on" << "\n";
    std::cout << "                      subsequent appearances in #include lines." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -d {name}={file}  Use {file} for macro {name} if it appears in an #include" << "\n";
    std::cout << "                      line." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -i {dir}          Additionally look in the specified directory for files when" << "\n";
    std::cout << "                      processing #include lines." << "\n";
    std::cout << "  " << "\n";
    std::cout << "    -v                Verbose output mode" << "\n";
    std::cout << "\n";
  }

  return error ? 1 : 0;
}
Example #23
0
  ParsedInclude parseInclude (String const& line, String const& trimmed)
  {
    ParsedInclude parsed;

    if (trimmed.startsWithChar ('#'))
    {
      const String removed = trimmed.removeCharacters (" \t");

      if (removed.startsWithIgnoreCase ("#include\""))
      {
        parsed.endOfInclude = line.indexOfChar (line.indexOfChar ('\"') + 1, '\"') + 1;
        parsed.filename = line.fromFirstOccurrenceOf ("\"", false, false)
                              .upToLastOccurrenceOf ("\"", false, false);

        parsed.isIncludeLine = true;

        parsed.preventReinclude = m_preventReincludes.contains (parsed.filename);
        parsed.forceReinclude = m_forceReincludes.contains (parsed.filename);
      }
      else if (removed.startsWithIgnoreCase ("#include<"))
      {
        if (m_checkSystemIncludes) {
          parsed.endOfInclude = line.indexOfChar (line.indexOfChar ('<') + 1, '>') + 1;
          parsed.filename = line.fromFirstOccurrenceOf ("<", false, false)
                                .upToLastOccurrenceOf (">", false, false);
          parsed.isIncludeLine = true;

          parsed.preventReinclude = m_preventReincludes.contains (parsed.filename);
          parsed.forceReinclude = m_forceReincludes.contains (parsed.filename);
        }
      }
      else if (removed.startsWithIgnoreCase ("#include"))
      {
        String name;

#if 1 
        if (line.contains ("/*"))
          name = line.fromFirstOccurrenceOf ("#include", false, false)
                     .upToFirstOccurrenceOf ("/*", false, false).trim ();
        else
          name = line.fromFirstOccurrenceOf ("#include", false, false).trim ();

        parsed.endOfInclude = line.upToFirstOccurrenceOf (name, true, false).length ();
#else
        name = line.fromFirstOccurrenceOf ("#include", false, false).trim ();
#endif

        String value = m_macrosDefined [name];

        if (m_verbose)
          std::cout << "name = " << name << "\n";

        if (value.startsWithIgnoreCase ("\""))
        {
          parsed.endOfInclude = line.trimEnd().length () + 1;
          parsed.filename = value.fromFirstOccurrenceOf ("\"", false, false)
                                .upToLastOccurrenceOf ("\"", false, false);

          parsed.isIncludeLine = true;
        }
        else if (value.startsWithIgnoreCase ("<") && m_checkSystemIncludes)
        {
          parsed.endOfInclude = line.trimEnd().length () + 1;
          parsed.filename = value.fromFirstOccurrenceOf ("<", false, false)
                                .upToLastOccurrenceOf (">", false, false);
          parsed.isIncludeLine = true;
        }

        parsed.preventReinclude = parsed.isIncludeLine && m_preventReincludes.contains (name);
        parsed.forceReinclude = parsed.isIncludeLine && m_forceReincludes.contains (name);
      }
    }

    return parsed;
  }