Exemple #1
0
static void formatNode( OUTPUTFORMATTER* out, int aNestLevel, int aCtl,
        const std::string& aKey, CPTREE& aTree )
    throw( IO_ERROR )
{
    if( !isAtom( aTree ) )     // is a list, not an atom
    {
        int ctl = CTL_OMIT_NL;

        // aTree is list and its first child is a list
        if( aTree.size() && !isAtom( aTree.begin()->second ) && !aTree.data().size() )
            ctl = 0;

        out->Print( aNestLevel, "(%s%s", out->Quotes( aKey ).c_str(), ctl & CTL_OMIT_NL ? "" : "\n" );

        if( aTree.data().size() )   // only xml typically uses "data()", not sexpr.
        {
            out->Print( 0, " %s%s",
                out->Quotes( aTree.data() ).c_str(),
                aTree.size() ? "\n" : ""
                );
        }

        formatList( out, aNestLevel, aCtl, aTree );

        out->Print( 0, ")%s", aCtl & CTL_OMIT_NL ? "" : "\n" );
    }

    else            // is an atom, not a list
    {
        const char* atom = out->Quotes( aKey ).c_str();
        out->Print( 0, " %s", atom );
    }
}
Exemple #2
0
QVector<QTextLayout::FormatRange> ChatItem::selectionFormats() const
{
    if (!hasSelection())
        return QVector<QTextLayout::FormatRange>();

    int start, end;
    if (_selectionMode == FullSelection) {
        start = 0;
        end = data(MessageModel::DisplayRole).toString().length();
    }
    else {
        start = qMin(_selectionStart, _selectionEnd);
        end = qMax(_selectionStart, _selectionEnd);
    }

    UiStyle::FormatList fmtList = formatList();

    while (fmtList.count() > 1 && fmtList.at(1).first <= start)
        fmtList.removeFirst();

    fmtList.first().first = start;

    while (fmtList.count() > 1 && fmtList.last().first >= end)
        fmtList.removeLast();

    return QtUi::style()->toTextLayoutList(fmtList, end, UiStyle::Selected|data(ChatLineModel::MsgLabelRole).toUInt()).toVector();
}
Exemple #3
0
/**
 * Format the current status information and place it in the given stream.
 * @param out Define the output stream to use.
 * @param prefix Define the string th place before each parameter name.
 * @param separator Define the string to place between the parameter name and the value.
 * @param postfix Define the string to place after the parameter value.
 * @param filter Provide a function to filter the string before printing it.
 *        It's usefull for XML escaping for example.
 */
void svutStatusInfo::formatContext(std::ostream& out, const char* prefix, const char* separator, const char* postfix,svutStringFilter filter) const
{
    std::string pre(prefix);
    std::string  sep(separator);
    std::string post(postfix);
    formatList(context,out,pre,sep,post,filter);
}
Exemple #4
0
static void formatList( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, CPTREE& aTree )

{
    for( CITER it = aTree.begin();  it != aTree.end();  ++it )
    {
        // Processing a tree which was read in with xml_parser?
        if( it->first == "<xmlattr>" )
        {
            formatList( out, aNestLevel, aCtl | CTL_IN_ATTRS, it->second );
            continue;
        }

        int ctl = 0;

        if( isLast( aTree, it ) )   // is "it" the last one?
        {
            //if( !( aCtl & CTL_IN_ATTRS ) )
                ctl = CTL_OMIT_NL;
        }
        else if( isAtom( next( it )->second ) )
        {
            /* if( !( aCtl & CTL_IN_ATTRS ) ) */
                ctl = CTL_OMIT_NL;
        }

        formatNode( out, aNestLevel+1, ctl, it->first, it->second );
    }
}
void ChatItem::initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode wrapMode, Qt::Alignment alignment) const {
  Q_ASSERT(layout);

  layout->setText(data(MessageModel::DisplayRole).toString());

  QTextOption option;
  option.setWrapMode(wrapMode);
  option.setAlignment(alignment);
  layout->setTextOption(option);

  QList<QTextLayout::FormatRange> formatRanges
         = QtUi::style()->toTextLayoutList(formatList(), layout->text().length(), data(ChatLineModel::MsgLabelRole).toUInt());
  layout->setAdditionalFormats(formatRanges);
}
nsresult
AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
                                         const nsTArray<uint8_t>& aExtraData)
{
  // Request the properties from CoreAudio using the codec magic cookie
  AudioFormatInfo formatInfo;
  PodZero(&formatInfo.mASBD);
  formatInfo.mASBD.mFormatID = mFormatID;
  if (mFormatID == kAudioFormatMPEG4AAC) {
    formatInfo.mASBD.mFormatFlags = mConfig.extended_profile;
  }
  formatInfo.mMagicCookieSize = aExtraData.Length();
  formatInfo.mMagicCookie = aExtraData.Elements();

  UInt32 formatListSize;
  // Attempt to retrieve the default format using
  // kAudioFormatProperty_FormatInfo method.
  // This method only retrieves the FramesPerPacket information required
  // by the decoder, which depends on the codec type and profile.
  aDesc.mFormatID = mFormatID;
  aDesc.mChannelsPerFrame = mConfig.channel_count;
  aDesc.mSampleRate = mConfig.samples_per_second;
  UInt32 inputFormatSize = sizeof(aDesc);
  OSStatus rv = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo,
                                       0,
                                       NULL,
                                       &inputFormatSize,
                                       &aDesc);
  if (NS_WARN_IF(rv)) {
    return NS_ERROR_FAILURE;
  }

  // If any of the methods below fail, we will return the default format as
  // created using kAudioFormatProperty_FormatInfo above.
  rv = AudioFormatGetPropertyInfo(kAudioFormatProperty_FormatList,
                                  sizeof(formatInfo),
                                  &formatInfo,
                                  &formatListSize);
  if (rv || (formatListSize % sizeof(AudioFormatListItem))) {
    return NS_OK;
  }
  size_t listCount = formatListSize / sizeof(AudioFormatListItem);
  nsAutoArrayPtr<AudioFormatListItem> formatList(
    new AudioFormatListItem[listCount]);

  rv = AudioFormatGetProperty(kAudioFormatProperty_FormatList,
                              sizeof(formatInfo),
                              &formatInfo,
                              &formatListSize,
                              formatList);
  if (rv) {
    return NS_OK;
  }
  LOG("found %u available audio stream(s)",
      formatListSize / sizeof(AudioFormatListItem));
  // Get the index number of the first playable format.
  // This index number will be for the highest quality layer the platform
  // is capable of playing.
  UInt32 itemIndex;
  UInt32 indexSize = sizeof(itemIndex);
  rv = AudioFormatGetProperty(kAudioFormatProperty_FirstPlayableFormatFromList,
                              formatListSize,
                              formatList,
                              &indexSize,
                              &itemIndex);
  if (rv) {
    return NS_OK;
  }

  aDesc = formatList[itemIndex].mASBD;

  return NS_OK;
}
Exemple #7
0
/**
 * Format the current status information and place it in the given stream.
 * @param out Define the output stream to use.
 * @param prefix Define the string th place before each parameter name.
 * @param separator Define the string to place between the parameter name and the value.
 * @param postfix Define the string to place after the parameter value.
 * @param filter Provide a function to filter the string before printing it.
 *        It's usefull for XML escaping for example.
 */
void svutStatusInfo::formatContext(std::ostream& out, const std::string& prefix, const std::string& separator, const std::string& postfix,svutStringFilter filter) const
{
    formatList(context,out,prefix,separator,postfix,filter);
}