/[svn]/libgig/trunk/src/helper.h
ViewVC logotype

Diff of /libgig/trunk/src/helper.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 929 by schoenebeck, Tue Oct 24 22:24:45 2006 UTC revision 1330 by persson, Sun Sep 9 10:36:23 2007 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file loader library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003-2006 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2006 by Christian Schoenebeck                      *
6   *                              <cuse@users.sourceforge.net>               *   *                              <cuse@users.sourceforge.net>               *
# Line 28  Line 28 
28  #include <string>  #include <string>
29  #include <sstream>  #include <sstream>
30    
31    #if defined(WIN32) && !HAVE_CONFIG_H
32    # include "../win32/libgig_private.h" // like config.h, automatically generated by Dev-C++
33    # define PACKAGE "libgig"
34    # define VERSION VER_STRING // VER_STRING defined in libgig_private.h
35    #endif // WIN32
36    
37  #include "RIFF.h"  #include "RIFF.h"
38    
39  // *************** Helper Functions **************  // *************** Helper Functions **************
# Line 48  inline long Abs(long val) { Line 54  inline long Abs(long val) {
54  }  }
55    
56  /**  /**
57     * Stores a 16 bit integer in memory using little-endian format.
58     *
59     * @param pData - memory pointer
60     * @param data  - integer to be stored
61     */
62    inline void store16(uint8_t* pData, uint16_t data) {
63        pData[0] = data;
64        pData[1] = data >> 8;
65    }
66    
67    /**
68     * Stores a 32 bit integer in memory using little-endian format.
69     *
70     * @param pData - memory pointer
71     * @param data  - integer to be stored
72     */
73    inline void store32(uint8_t* pData, uint32_t data) {
74        pData[0] = data;
75        pData[1] = data >> 8;
76        pData[2] = data >> 16;
77        pData[3] = data >> 24;
78    }
79    
80    /**
81   * Swaps the order of the data words in the given memory area   * Swaps the order of the data words in the given memory area
82   * with a granularity given by \a WordSize.   * with a granularity given by \a WordSize.
83   *   *
# Line 144  inline void SaveString(uint32_t ChunkID, Line 174  inline void SaveString(uint32_t ChunkID,
174          ck->Resize(size);          ck->Resize(size);
175          char* pData = (char*) ck->LoadChunkData();          char* pData = (char*) ck->LoadChunkData();
176          strncpy(pData, s.c_str(), size);          strncpy(pData, s.c_str(), size);
177      } else if (s != "" || sDefault != "") { // create chunk      } else if (s != "" || sDefault != "" || bUseFixedLengthStrings) { // create chunk
178          const std::string& sToSave = (s != "") ? s : sDefault;          const std::string& sToSave = (s != "") ? s : sDefault;
179          if (!bUseFixedLengthStrings) size = sToSave.size() + 1;          if (!bUseFixedLengthStrings) size = sToSave.size() + 1;
180          ck = lstINFO->AddSubChunk(ChunkID, size);          ck = lstINFO->AddSubChunk(ChunkID, size);

Legend:
Removed from v.929  
changed lines
  Added in v.1330

  ViewVC Help
Powered by ViewVC