Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
commit6249432407af8730c10bccc7894c0725fcaf5e47 (patch)
tree3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /biconcor/base64.cpp
parent59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff)
beautify
Diffstat (limited to 'biconcor/base64.cpp')
-rw-r--r--biconcor/base64.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/biconcor/base64.cpp b/biconcor/base64.cpp
index 2a863d161..8032399b5 100644
--- a/biconcor/base64.cpp
+++ b/biconcor/base64.cpp
@@ -1,4 +1,4 @@
-/*
+/*
base64.cpp and base64.h
Copyright (C) 2004-2008 René Nyffenegger
@@ -28,17 +28,19 @@
#include "base64.h"
#include <iostream>
-static const std::string base64_chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
+static const std::string base64_chars =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
-static inline bool is_base64(unsigned char c) {
+static inline bool is_base64(unsigned char c)
+{
return (isalnum(c) || (c == '+') || (c == '/'));
}
-std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
+std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len)
+{
std::string ret;
int i = 0;
int j = 0;
@@ -59,8 +61,7 @@ std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_
}
}
- if (i)
- {
+ if (i) {
for(j = i; j < 3; j++)
char_array_3[j] = '\0';
@@ -81,7 +82,8 @@ std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_
}
-std::string base64_decode(std::string const& encoded_string) {
+std::string base64_decode(std::string const& encoded_string)
+{
int in_len = encoded_string.size();
int i = 0;
int j = 0;
@@ -90,7 +92,8 @@ std::string base64_decode(std::string const& encoded_string) {
std::string ret;
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
- char_array_4[i++] = encoded_string[in_]; in_++;
+ char_array_4[i++] = encoded_string[in_];
+ in_++;
if (i ==4) {
for (i = 0; i <4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);