Example #1
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 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 #3
0
void LR_IPC_IN::processLine(const String& line)
{
	// process input into [parameter] [Value]
	line.trimEnd();
	String command = line.upToFirstOccurrenceOf(" ", false, false);
	String valueString = line.replace(line.upToFirstOccurrenceOf(" ", true, true), "", true);
	auto value = valueString.getIntValue();

	// store updates in map
	parameterMap[command] = value;

	// send associated CC messages to MIDI OUT devices
	if (CommandMap::getInstance().commandHasAssociatedMessage(command))
	{
		const MIDI_Message& msg = CommandMap::getInstance().getMessageForCommand(command);
		MIDISender::getInstance().sendCC(msg.channel, msg.controller, value);
	}
}
Example #4
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 #5
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 #6
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 #7
0
//==============================================================================
bool URL::isProbablyAWebsiteURL (const String& possibleURL)
{
    static const char* validProtocols[] = { "http:", "ftp:", "https:" };

    for (auto* protocol : validProtocols)
        if (possibleURL.startsWithIgnoreCase (protocol))
            return true;

    if (possibleURL.containsChar ('@')
        || possibleURL.containsChar (' '))
        return false;

    const String topLevelDomain (possibleURL.upToFirstOccurrenceOf ("/", false, false)
                                 .fromLastOccurrenceOf (".", false, false));

    return topLevelDomain.isNotEmpty() && topLevelDomain.length() <= 3;
}
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
//==============================================================================
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 #10
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;
  }
Example #11
0
void Blender::actionListenerCallback(const String &message)
{
    int mixer_id = 0;
    int channel_id = 0;
    int mixer_id_index = message.indexOfChar(':') + 1;
    int channel_id_index = message.indexOfChar('+') + 1;
    String idStr(String::empty);
    String type(message.upToFirstOccurrenceOf(":", false, false));
    String valStr(message.fromLastOccurrenceOf("=", false, false));
    uint32 value = valStr.getIntValue();
    bool bUpdateGui = false;

    if (mixer_id_index >= 0)
    {
        idStr = message.substring(mixer_id_index, mixer_id_index+2);
        mixer_id = idStr.getIntValue();

        if (channel_id_index >= 0)
        {
            idStr = message.substring(channel_id_index, channel_id_index+2);
            channel_id = idStr.getIntValue();

            if (0 == type.compare("gain"))
            {
                int gain = jmin<int>(130, (int)value);
                m_bl_desc.mixer[mixer_id].channel[channel_id].gain = gain;
                m_bl_desc.mixer[mixer_id].channel[channel_id].gain_dbv = m_dBvMap[gain];
            }
            else if (0 == type.compare("master_gain"))
            {
                // master gain
                int gain = jmin<int>(130, (int)value);
                m_bl_desc.mixer[mixer_id].master.gain = gain;
                m_bl_desc.mixer[mixer_id].master.gain_dbv = m_dBvMap[gain];
            }
            else if (0 == type.compare("pan"))
            {
                // channel strip pan
                m_bl_desc.mixer[mixer_id].channel[channel_id].pan = (int)value;
            }
            else if (0 == type.compare("master_mute"))
            {
                // master out mute
                m_bl_desc.mixer[mixer_id].master.muting = (value != 0);
            }
            else if (0 == type.compare("mute"))
            {
                uint32 muting = (uint32)value;
                uint32 channel_bit = 1<<channel_id;

                // channel strip mute
                if (muting)
                {
                    // mute
                    m_bl_desc.mixer[mixer_id].mutes |= channel_bit;
                    m_bl_desc.mixer[mixer_id].was_muted |= channel_bit;

                    // handle solos
                    if (0 != m_bl_desc.mixer[mixer_id].solos)
                    {
                        if (m_bl_desc.mixer[mixer_id].solos == channel_bit)
                        {
                            // a solo was active only on that channel, unsolo all and restore mutes
                            m_bl_desc.mixer[mixer_id].solos = 0;
                            m_bl_desc.mixer[mixer_id].mutes = m_bl_desc.mixer[mixer_id].was_muted;
                            bUpdateGui = true;
                        }
                        // other solos are active, unsolo only this one if soloed
                        else if (m_bl_desc.mixer[mixer_id].solos & channel_bit)
                        {
                            m_bl_desc.mixer[mixer_id].solos ^= channel_bit;
                            m_bl_desc.mixer[mixer_id].mutes |= (m_bl_desc.mixer[mixer_id].was_muted & channel_id);
                            bUpdateGui = true;
                        }
                    }
                }
                else
                {
                    // unmute
                    m_bl_desc.mixer[mixer_id].mutes ^= channel_bit;
                    m_bl_desc.mixer[mixer_id].was_muted ^= channel_bit;

                    // handle solos
                    if (0 != m_bl_desc.mixer[mixer_id].solos)
                    {
                        // a solo was active on another channel, solo this one too
                        m_bl_desc.mixer[mixer_id].solos |= channel_bit;
                        bUpdateGui = true;
                    }
                }
            }
            else if (0 == type.compare("solo"))
            {
                uint32 soloing = (uint32)value;
                uint32 channel_bit = 1<<channel_id;

                if (soloing)
                {
                    // is this the first soloed channel?
                    if (0 == m_bl_desc.mixer[mixer_id].solos)
                    {
                        // solo
                        m_bl_desc.mixer[mixer_id].solos |= channel_bit;

                        // mute all others
                        m_bl_desc.mixer[mixer_id].mutes = ~channel_bit;
                        bUpdateGui = true;
                    }
                    else
                    {
                        // solo this one also
                        m_bl_desc.mixer[mixer_id].solos |= channel_bit;
                        m_bl_desc.mixer[mixer_id].mutes ^= channel_bit;
                        bUpdateGui = true;
                    }
                }
                else
                {
                    // channel was soloed

                    // was this the only soloed channel?
                    if (m_bl_desc.mixer[mixer_id].solos == channel_bit)
                    {
                        // unsolo all
                        m_bl_desc.mixer[mixer_id].solos = 0;

                        // restore mute states
                        m_bl_desc.mixer[mixer_id].mutes = m_bl_desc.mixer[mixer_id].was_muted;
                        bUpdateGui = true;
                    }
                    else
                    {
                        // other channels are soloed, so unsolo this one only
                        m_bl_desc.mixer[mixer_id].solos ^= channel_bit;

                        // restore mute state
                        if (m_bl_desc.mixer[mixer_id].was_muted & channel_bit)
                        {
                            m_bl_desc.mixer[mixer_id].mutes |= channel_bit;
                        }
                        bUpdateGui = true;
                    }
                }

            }
            else if (0 == type.compare("dirout"))
            {
                m_bl_desc.mixer[mixer_id].direct_out = (0 != value);

                setDirectOut(mixer_id);
                sendDirout(mixer_id, m_bl_desc.mixer[mixer_id].direct_out);
                String msg(String::formatted("dirout: mixer id:%d, %d", mixer_id, m_bl_desc.mixer[mixer_id].direct_out));
                EventLogger::getInstance()->logMessage(msg);
            }
            else if (0 == type.compare("reset"))
            {
                for (int i=0; i<m_bl_desc.mixer[mixer_id].num_channels; i++)
                {
                    m_bl_desc.mixer[mixer_id].channel[i].gain = 101;
                    m_bl_desc.mixer[mixer_id].channel[i].gain_dbv = m_dBvMap[101];
                    sendChGain(mixer_id, i, 101);
                    m_bl_desc.mixer[mixer_id].channel[i].pan = 0;
                    sendChPan(mixer_id, i, 0);
                }
                m_bl_desc.mixer[mixer_id].mutes = 0;
                m_bl_desc.mixer[mixer_id].was_muted = 0;
                sendChMutes(mixer_id, m_bl_desc.mixer[mixer_id].mutes);
                m_bl_desc.mixer[mixer_id].solos = 0;
                sendChSolos(mixer_id, m_bl_desc.mixer[mixer_id].solos);

                m_bl_desc.mixer[mixer_id].master.gain = 101;
                m_bl_desc.mixer[mixer_id].master.gain_dbv = m_dBvMap[101];
                sendMasterGain(mixer_id, 101);
                m_bl_desc.mixer[mixer_id].master.muting = false;
                sendMasterMute(mixer_id, false);

                m_bl_desc.mixer[mixer_id].direct_out = 0;
                setDirectOut(mixer_id);
                sendDirout(mixer_id, 0);

                bUpdateGui = true;
            }
            // update mixer coeff's
            mixer_cfg(mixer_id);
        }

        if (bUpdateGui)
        {
            sendChMutes(mixer_id, m_bl_desc.mixer[mixer_id].mutes);
            sendChSolos(mixer_id, m_bl_desc.mixer[mixer_id].solos);
        }
    }
}