当前位置: 首页>>代码示例>>C++>>正文


C++ MemoryBlock::setSize方法代码示例

本文整理汇总了C++中MemoryBlock::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBlock::setSize方法的具体用法?C++ MemoryBlock::setSize怎么用?C++ MemoryBlock::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemoryBlock的用法示例。


在下文中一共展示了MemoryBlock::setSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: key

    static std::uint32_t getBinaryValue (const String& regValuePath, MemoryBlock& result, DWORD wow64Flags)
    {
        const RegistryKeyWrapper key (regValuePath, false, wow64Flags);

        if (key.key != 0)
        {
            for (unsigned long bufferSize = 1024; ; bufferSize *= 2)
            {
                result.setSize (bufferSize, false);
                DWORD type = REG_NONE;

                const LONG err = RegQueryValueEx (key.key, key.wideCharValueName, 0, &type,
                                                  (LPBYTE) result.getData(), &bufferSize);

                if (err == ERROR_SUCCESS)
                {
                    result.setSize (bufferSize, false);
                    return type;
                }

                if (err != ERROR_MORE_DATA)
                    break;
            }
        }

        return REG_NONE;
    }
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:27,代码来源:win32_Registry.cpp

示例2: readNextLine

String InputStream::readNextLine()
{
    MemoryBlock buffer (256);
    char* data = static_cast<char*> (buffer.getData());
    size_t i = 0;

    while ((data[i] = readByte()) != 0)
    {
        if (data[i] == '\n')
            break;

        if (data[i] == '\r')
        {
            const int64 lastPos = getPosition();

            if (readByte() != '\n')
                setPosition (lastPos);

            break;
        }

        if (++i >= buffer.getSize())
        {
            buffer.setSize (buffer.getSize() + 512);
            data = static_cast<char*> (buffer.getData());
        }
    }

    return String::fromUTF8 (data, (int) i);
}
开发者ID:AlessandroGiacomini,项目名称:pyplasm,代码行数:30,代码来源:juce_InputStream.cpp

示例3: getStateInformation

    //==============================================================================
    void getStateInformation (MemoryBlock& destData)
    {
        destData.setSize (sizeof (float) * getNumParameters());
        destData.fillWith (0);

        float* const p = (float*) ((char*) destData.getData());
        for (int i = 0; i < getNumParameters(); ++i)
            p[i] = getParameter(i);
    }
开发者ID:JayaWei,项目名称:ambix,代码行数:10,代码来源:juce_LADSPAPluginFormat.cpp

示例4: readFromStream

var var::readFromStream (InputStream& input)
{
    const int numBytes = input.readCompressedInt();

    if (numBytes > 0)
    {
        switch (input.readByte())
        {
            case varMarker_Int:         return var (input.readInt());
            case varMarker_Int64:       return var (input.readInt64());
            case varMarker_BoolTrue:    return var (true);
            case varMarker_BoolFalse:   return var (false);
            case varMarker_Double:      return var (input.readDouble());
            case varMarker_String:
            {
                MemoryOutputStream mo;
                mo.writeFromInputStream (input, numBytes - 1);
                return var (mo.toUTF8());
            }

            case varMarker_Binary:
            {
                MemoryBlock mb (numBytes - 1);

                if (numBytes > 1)
                {
                    const int numRead = input.read (mb.getData(), numBytes - 1);
                    mb.setSize (numRead);
                }

                return var (mb);
            }

            case varMarker_Array:
            {
                var v;
                Array<var>* const destArray = v.convertToArray();

                for (int i = input.readCompressedInt(); --i >= 0;)
                    destArray->add (readFromStream (input));

                return v;
            }

            default:
                input.skipNextBytes (numBytes - 1); break;
        }
    }

    return var::null;
}
开发者ID:anthonyhuecouret,项目名称:argotlunar,代码行数:51,代码来源:juce_Variant.cpp

示例5: readString

String InputStream::readString()
{
    MemoryBlock buffer (256);
    char* data = static_cast<char*> (buffer.getData());
    size_t i = 0;

    while ((data[i] = readByte()) != 0)
    {
        if (++i >= buffer.getSize())
        {
            buffer.setSize (buffer.getSize() + 512);
            data = static_cast<char*> (buffer.getData());
        }
    }

    return String::fromUTF8 (data, (int) i);
}
开发者ID:AlessandroGiacomini,项目名称:pyplasm,代码行数:17,代码来源:juce_InputStream.cpp

示例6: trimFileSize

void FileLogger::trimFileSize (int maxFileSizeBytes) const
{
    if (maxFileSizeBytes <= 0)
    {
        logFile.deleteFile();
    }
    else
    {
        const int64 fileSize = logFile.getSize();

        if (fileSize > maxFileSizeBytes)
        {
            ScopedPointer <FileInputStream> in (logFile.createInputStream());
            jassert (in != nullptr);

            if (in != nullptr)
            {
                in->setPosition (fileSize - maxFileSizeBytes);
                String content;

                {
                    MemoryBlock contentToSave;
                    contentToSave.setSize ((size_t) maxFileSizeBytes + 4);
                    contentToSave.fillWith (0);

                    in->read (contentToSave.getData(), maxFileSizeBytes);
                    in = nullptr;

                    content = contentToSave.toString();
                }

                int newStart = 0;

                while (newStart < fileSize
                        && content[newStart] != '\n'
                        && content[newStart] != '\r')
                    ++newStart;

                logFile.deleteFile();
                logFile.appendText (content.substring (newStart), false, false);
            }
        }
    }
}
开发者ID:belasco,项目名称:GpxDBImporterExporter,代码行数:44,代码来源:juce_FileLogger.cpp

示例7: create

    static void create (MemoryBlock& block, const StringPairArray& values)
    {
        if (values.getAllKeys().contains ("MidiUnityNote", true))
        {
            block.setSize ((sizeof (InstChunk) + 3) & ~3, true);
            InstChunk* const inst = static_cast <InstChunk*> (block.getData());

            inst->baseNote      = (int8) values.getValue ("MidiUnityNote", "60").getIntValue();
            inst->detune        = (int8) values.getValue ("Detune", "0").getIntValue();
            inst->lowNote       = (int8) values.getValue ("LowNote", "0").getIntValue();
            inst->highNote      = (int8) values.getValue ("HighNote", "127").getIntValue();
            inst->lowVelocity   = (int8) values.getValue ("LowVelocity", "1").getIntValue();
            inst->highVelocity  = (int8) values.getValue ("HighVelocity", "127").getIntValue();
            inst->gain          = (int16) ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Gain", "0").getIntValue());

            inst->sustainLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0Type", "0").getIntValue());
            inst->sustainLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0StartIdentifier", "0").getIntValue());
            inst->sustainLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0EndIdentifier", "0").getIntValue());
            inst->releaseLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1Type", "0").getIntValue());
            inst->releaseLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1StartIdentifier", "0").getIntValue());
            inst->releaseLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1EndIdentifier", "0").getIntValue());
        }
    }
开发者ID:EQ4,项目名称:editor,代码行数:23,代码来源:juce_AiffAudioFormat.cpp

示例8: loadFromCpp

void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cppFile)
{
    StringArray cpp;
    cpp.addLines (cppFile);

    clear();

    for (int i = 0; i < cpp.size(); ++i)
    {
        if (cpp[i].contains ("JUCER_RESOURCE:"))
        {
            StringArray tokens;
            tokens.addTokens (cpp[i].fromFirstOccurrenceOf (":", false, false), ",", "\"'");
            tokens.trim();
            tokens.removeEmptyStrings();

            const String resourceName (tokens[0]);
            const int resourceSize = tokens[1].getIntValue();
            const String originalFileName (cppFileLocation.getSiblingFile (tokens[2].unquoted()).getFullPathName());

            jassert (resourceName.isNotEmpty() && resourceSize > 0);

            if (resourceName.isNotEmpty() && resourceSize > 0)
            {
                const int firstLine = i;

                while (i < cpp.size())
                    if (cpp [i++].contains ("}"))
                        break;

                const String dataString (cpp.joinIntoString (" ", firstLine, i - firstLine)
                                            .fromFirstOccurrenceOf ("{", false, false));

                MemoryOutputStream out;
                String::CharPointerType t (dataString.getCharPointer());
                int n = 0;

                while (! t.isEmpty())
                {
                    const juce_wchar c = t.getAndAdvance();

                    if (c >= '0' && c <= '9')
                        n = n * 10 + (c - '0');
                    else if (c == ',')
                    {
                        out.writeByte ((char) n);
                        n = 0;
                    }
                    else if (c == '}')
                        break;
                }

                jassert (resourceSize < (int) out.getDataSize() && resourceSize > (int) out.getDataSize() - 2);

                MemoryBlock mb (out.getData(), out.getDataSize());
                mb.setSize ((size_t) resourceSize);

                add (resourceName, originalFileName, mb);
            }
        }
    }
}
开发者ID:AlessandroGiacomini,项目名称:pyplasm,代码行数:62,代码来源:jucer_BinaryResources.cpp

示例9: loadData


//.........这里部分代码省略.........
    int nRecs = 0;
    std::list<int> * pages = new std::list<int>();
    MemoryBlock * data = new MemoryBlock(m_pageSize);
    char * holder = new char[recordsPerPage*nBytesPerRecord];

    for(int k = 0; k < nRecords;)
    {
      int recordsRead = 0;
      if ((nRecords - k) < recordsPerPage)
      {
        recordsRead = nRecords-k;
      }
      else
      {
        recordsRead = recordsPerPage;
      }
    
      table.read(holder,recordsRead*nBytesPerRecord);
      k+= recordsRead;
      
      int hOffset = 0;
      for (int r = 0; r < recordsRead; r++)
      {
        for (int z = 0; z < nFields; z++)
        {
	 
          int fB = FtoBMap[z];
          int currentPartition = FtoPMap[z];
          int writeLocation = currentPositions[currentPartition];
	
 
          data->put((byte*)holder + hOffset, writeLocation, fB);
	
	  currentPositions[currentPartition] = writeLocation + fB;

          hOffset += fB;
        }	
      }
      
      for(int l = 0; l < nPartitions; l++)
      {
        currentPositions[l] = startPositions[l];
      }
      pages->push_back(bufferLoc);
      data->setSize(recordsRead);
      DiskPage *dp = new DiskPage(a, data, tableName);
      bufferLoc++;
      m_files.push_back(dp);
      data = new MemoryBlock(m_pageSize);
    }
    m_namePagesMap[tableName] = pages;
    table.close();

    /*for (int k = 0; k < nRecords; k++)
    {
      if(nRecs == recordsPerPage)
      {
        pages->push_back(bufferLoc);
        bufferLoc++;
        for(int l = 0; l < nPartitions; l++)
	{
           currentPositions[l] = startPositions[l];
        }
	DiskPage * dp = new DiskPage(a,data,tableName);
	data->setSize(nRecs);
	nRecs = 0;
	data = new MemoryBlock(m_pageSize);
        m_files.push_back(dp);
      }
      
      for (int z = 0; z < nFields; z++)
      {
	
        int fB = FtoBMap[z];
        int currentPartition = FtoPMap[z];
        int writeLocation = currentPositions[currentPartition];
	
	
	char * wrt = new char[fB];
	
        table.read(wrt,fB);
        data->put((byte*)wrt, writeLocation, fB);
        delete [] wrt;
	
	currentPositions[currentPartition] = writeLocation + fB;
	
      }
      nRecs++;
    }
    pages->push_back(bufferLoc);
    data->setSize(nRecs);
    DiskPage *dp = new DiskPage(a, data, tableName);
    bufferLoc++;
    m_files.push_back(dp);
    m_namePagesMap[tableName] = pages;
    table.close();
    */    
  }
  pageFormat.close();
}
开发者ID:Adamanthil,项目名称:DBCacheBenchmarking,代码行数:101,代码来源:FileManager.cpp


注:本文中的MemoryBlock::setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。