Sha256: 9ed1913e0e4a84acc2b28dd4f4444ca4bf46d3712ffdda8601afbd7fd0fc2990

Contents?: true

Size: 1.03 KB

Versions: 60

Compression:

Stored size: 1.03 KB

Contents

#include "sass.hpp"
#include "base64vlq.hpp"

namespace Sass {

  std::string Base64VLQ::encode(const int number) const
  {
    std::string encoded = "";

    int vlq = to_vlq_signed(number);

    do {
      int digit = vlq & VLQ_BASE_MASK;
      vlq >>= VLQ_BASE_SHIFT;
      if (vlq > 0) {
        digit |= VLQ_CONTINUATION_BIT;
      }
      encoded += base64_encode(digit);
    } while (vlq > 0);

    return encoded;
  }

  char Base64VLQ::base64_encode(const int number) const
  {
    int index = number;
    if (index < 0) index = 0;
    if (index > 63) index = 63;
    return CHARACTERS[index];
  }

  int Base64VLQ::to_vlq_signed(const int number) const
  {
    return (number < 0) ? ((-number) << 1) + 1 : (number << 1) + 0;
  }

  const char* Base64VLQ::CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

  const int Base64VLQ::VLQ_BASE_SHIFT = 5;
  const int Base64VLQ::VLQ_BASE = 1 << VLQ_BASE_SHIFT;
  const int Base64VLQ::VLQ_BASE_MASK = VLQ_BASE - 1;
  const int Base64VLQ::VLQ_CONTINUATION_BIT = VLQ_BASE;

}

Version data entries

60 entries across 58 versions & 17 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/node-sass/src/libsass/src/base64vlq.cpp
optimacms-0.1.61 spec/dummy/node_modules/@rails/webpacker/node_modules/node-sass/src/libsass/src/base64vlq.cpp
disco_app-0.18.0 test/dummy/node_modules/node-sass/src/libsass/src/base64vlq.cpp
disco_app-0.18.2 test/dummy/node_modules/node-sass/src/libsass/src/base64vlq.cpp
tang-0.2.1 spec/tang_app/node_modules/node-sass/src/libsass/src/base64vlq.cpp
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/node-sass/src/libsass/src/base64vlq.cpp
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/node-sass/src/libsass/src/base64vlq.cpp
ruby2js-4.0.4 lib/tasks/testrails/node_modules/node-sass/src/libsass/src/base64vlq.cpp
ruby2js-4.0.3 lib/tasks/testrails/node_modules/node-sass/src/libsass/src/base64vlq.cpp
tang-0.2.0 spec/tang_app/node_modules/node-sass/src/libsass/src/base64vlq.cpp
tang-0.1.0 spec/tang_app/node_modules/node-sass/src/libsass/src/base64vlq.cpp
tang-0.0.9 spec/tang_app/node_modules/node-sass/src/libsass/src/base64vlq.cpp
enju_library-0.3.8 spec/dummy/node_modules/node-sass/src/libsass/src/base64vlq.cpp
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sassc-2.0.0/ext/libsass/src/base64vlq.cpp
ilog-0.4.1 node_modules/node-sass/src/libsass/src/base64vlq.cpp
ilog-0.4.0 node_modules/node-sass/src/libsass/src/base64vlq.cpp
ilog-0.3.3 node_modules/node-sass/src/libsass/src/base64vlq.cpp
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/base64vlq.cpp
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/base64vlq.cpp
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.0.1/ext/libsass/src/base64vlq.cpp