text:
var server_address = 'http://localhost:8080'
var fuid = 0

var user_data = {}

InitializeUser = function(user){
    this.class_name = 'initialize_user';
    this.user = user;
}
InitializeUser.prototype.get_data_from_server = function(callback){
    var self = this;
    if (callback === undefined) { callback=function(){} }
    $.get(server_address+'/events/'+fuid, function(upcoming_events){
        self.events = JSON.parse(upcoming_events)
        callback()
    })
}
InitializeUser.prototype.init = function(events){
    var self = this
    this.get_data_from_server(function(){
        self.populate_user_profile();
        self.populate_upcoming();
        self.click_handlers();
    })
}
InitializeUser.prototype.populate_user_profile = function(){
    $('#profile-name').html(this.user['name']);
    $('#profile-image').attr('src', this.user['photo']);
    $('#popup-profile-name').html(this.user['name']);
    $('#popup-profile-image').attr('src', this.user['photo']);
    $('#popup-profile-email').html(this.user['email']);
}
InitializeUser.prototype.populate_upcoming = function(){
    var self = this;
    htmlstr = '';
    for( var i=0, len=this.events.length; i<len; i++ ){
        htmlstr +=
            "
"+
                "
"+
                    this.events[i]['due']+
                "
"+
                "
"+
                    "title"+ this.events[i]['name']+ ""+
                "
"+
                "
"+
                    "subject"+ this.events[i]['subject']+ ""+
                "
"+
                "
"+
                    "submission"+ this.events[i]['to']+ ""+
                "
"+
            "
"
    }
    $('#rcontent').html(htmlstr);

    // Now set up the click handlers
    event_cards = $('.event');
    for(var i = 0, len = event_cards.length; i<len; i++){
        $(event_cards[i]).click(function(){
            event_data = self.events[$($(this)[0]).data('event')]
            el_main = $('#event-popup').children()
            el_date = $($(el_main[1]).children()[1]).text(event_data['due'])
            el_title = $($(el_main[2]).children()[1]).text(event_data['name'])
            el_subject = $($(el_main[3]).children()[1]).text(event_data['subject'])
            el_submission = $($(el_main[4]).children()[1]).text(event_data['to'])
            el_desc = $($(el_main[5]).children()[3]).text(event_data['description'])
            $($('#event-popup').parent()).css('display', 'flex');
        });
    }
    $($('#event-popup').parent()).click(function(){
        $($('#event-popup').parent()).css('display', 'none');
    });
}
InitializeUser.prototype.click_handlers = function(){
    // User logout
    $('#popup-profile-signout-button').click(function(){
        var auth2 = gapi.auth2.getAuthInstance();
        auth2.signOut().then(function () {
            console.log('User signed out.');
        });
        $('#login-popup').css('display', 'flex');
        $($('#signout-popup').parent()).css('display', 'none');
    });
    // Handle sinout popup remove click
    $($('#signout-popup').parent()).click(function(){
        $($('#signout-popup').parent()).css('display', 'none');
    });
    $('#signout-popup').click(function(e){
        e.stopPropagation();
    });
    // Open up the signout popup
    $('#profile-image').click(function(){
        $($('#signout-popup').parent()).css('display', 'flex');
    });

    //other handles (menu items)
    $('#home').click(function(){
        new Home().init()
    });
    $('#notes').click(function(){
        new NotesView().init()
    });
    $('#about').click(function(){
        new AboutView().init()
    });
    $('#attendece').click(function(){
        new AttendenceView().init()
    });
    $('#calender').click(function(){
        new CalenderView().init()
    });
}

Home = function(){
    this.class_name = 'home'
}
Home.prototype.get_data_from_server = function(callback){
    var self = this;
    if (callback === undefined) { callback=function(){} }

    var day = new Date().getDay();
    var dow = ['sunday', 'monday', 'tuesday', 'wednessday', 'thursday', 'friday', 'saturday'][day]
    cur_date = String(day)+'-'+ String(new Date().getMonth()+1) + '-' + String(new Date().getFullYear())
    var pass_data = {
        'id': fuid,
        'date': cur_date,
        'day': dow
    }
    $.post(server_address+'/track_data/', { 'data': JSON.stringify(pass_data) }, function(track_data){
        $.get(server_address+'/subject_data/'+fuid, function(subject_data){
            $.get(server_address+'/timetable/'+fuid, function(timetable){
                self.timetable = timetable;
                self.subject_data = JSON.parse(subject_data);
                self.track_data = JSON.parse(track_data);
                callback()
            })
        })
    })
}
Home.prototype.init = function(){
    var self = this;
    this.get_data_from_server(function(){
        var day = new Date().getDay();
        var dow = ['sunday', 'monday', 'tuesday', 'wednessday', 'thursday', 'friday', 'saturday'][day]
        if(self.timetable[dow] != undefined){
            self.create_base_template();
            self.populate_timetable_heder();
            self.populate_subject_data(self.subject_data[(self.timetable[dow]).split(',')[0]], self.track_data[0],0);
            self.handlers();
        }
        else{
            text = "
It's a " + dow + ". You are free today!
"+
                ''
            $('#mcontent').html(text);
        }
    })
}
Home.prototype.create_base_template = function(){
    htmlstr =
        '
'+
            ''+
            '
'+
                'subject'+
                ''+
            '
'+
            '
'+
                'teacher'+
                ''+
            '
'+
            '
'+
                'time'+
                ''+
            '
'+
            '
'+
                'notes'+
            '
'+
            '<textarea id="notes-text" rows="15" placeholder="Boo, enter your notes here"></textarea>'+
        '
'
    $('#mcontent').html(htmlstr);
    this.notes_editor = new SimpleMDE({ element: document.getElementById("notes-text") });
    ne = this.notes_editor;  // Just to make it global for debug
}
// Populate the list of subjects
Home.prototype.populate_timetable_heder = function(timetable){
    var count = 0;
    for (var i in this.timetable) {
       if (this.timetable.hasOwnProperty(i)) count++;
    }
    htmlstr = ''
    var day = new Date().getDay();
    var dow = ['sunday', 'monday', 'tuesday', 'wednessday', 'thursday', 'friday', 'saturday'][day]
    for( var i=0; i<=count; i++ ){
        htmlstr+=
            "
"+
                (this.timetable[dow]).split(',')[i]+
            "
"
    }
    htmlstr =
        "
"+
            htmlstr+
        "
"
    $('#mcontent').prepend(htmlstr);
}
// Populate data for each subject ( called on user click )
Home.prototype.populate_subject_data = function(subject_data, period_data, period_number){
    $('#subject-name-content').html(subject_data['subject']);
    $('#teacher-name-content').html(subject_data['teacher']);
    $('#subject-time-content').html(period_data['time']);
    this.notes_editor.value(period_data['notes']);
    $('#subject-data').attr('data', period_number);
}
Home.prototype.post_track_data = function(){
    var self = this
    var day = new Date().getDay();
    var dow = ['sunday', 'monday', 'tuesday', 'wednessday', 'thursday', 'friday', 'saturday'][day]
    cur_date = String(day)+'-'+ String(new Date().getMonth()+1) + '-' + String(new Date().getFullYear())
    $.post(server_address+'/set_track_data/',{ 'track_data': JSON.stringify(self.track_data), 'id':fuid, 'date': cur_date, 'day': dow }, function(track_data){
        console.log('Updated track_data to server')
    })
}
Home.prototype.handlers = function(){
    var self = this;
    // Add in notes data to the variable
    this.notes_editor.codemirror.on("change", function(){
        note = self.notes_editor.value();
        period_number = $('#subject-data').attr('data');
        $.each(self.track_data, function(i, v) {    // probable to cause a bug
            if (v.period == period_number) {
                self.track_data[i].notes = note;
                return;
            }
        });
        self.post_track_data()
    });
    $('.timetable-subject').click(function(){
        var el = this;
        var day = new Date().getDay();
        var dow = ['sunday', 'monday', 'tuesday', 'wednessday', 'thursday', 'friday', 'saturday'][day]
        period_number = $(el).attr('data');
        $('#subject-data').attr('data', period_number);
        self.populate_subject_data(self.subject_data[(self.timetable[dow]).split(',')[period_number]], self.track_data[period_number], period_number);
        self.post_track_data()
    });
}

NotesView = function() {
    this.name = 'notesView';
    // filter with date and subject ( and even make requests based on that )
}
NotesView.prototype.get_data_from_server = function(callback){
    var self = this;
    if (callback === undefined) { callback=function(){} }
    $.get(server_address+'/notes/'+fuid, function(notes_data){
        self.notes_data = JSON.parse(notes_data);
        callback()
    })
}
NotesView.prototype.init = function(){
    var self = this
    this.get_data_from_server(function(){
        self.create_base_template()
        self.populate_notes()
    })
}
NotesView.prototype.populate_notes = function(){
    htmlstr = ''
    for(note in this.notes_data){
        s = ''
        if(this.notes_data[note]['note'].length < 1){
        s = 'display:none'}
            htmlstr +=  "

"+
                        "
"+
                        "date"+
                            this.notes_data[note]['date']+
                        "&nbsp&nbsp&nbsp"+
                        "subject"+
                            this.notes_data[note]['subject']+
                        ""+
                        "

"+
                        '<textarea class="notes-content" id="notes-content-' + note + '">'+
                            this.notes_data[note]['note']+
                        '</textarea>'+
                        '
'
        // }
    }
    $('#notes-view-data').html(htmlstr);
    editor_items_notes = $('.notes-content')
    for(var item=0, len=editor_items_notes.length; item<len; item++){
        elem = $('#notes-content-'+item)
        new SimpleMDE({
            element: elem[0],
            status: false,
            toolbar: false,
        }).togglePreview();
    }
}
NotesView.prototype.create_base_template = function(){
    htmlstr =
        '
'+
            'Notes'+
        '
'+
        '
'+
        '
'
    $('#mcontent').html(htmlstr);
}

AttendenceView = function() {
    this.name = 'attendenceView';
}
AttendenceView.prototype.get_data_from_server = function(callback){
    var self = this;
    if (callback === undefined) { callback=function(){} }
    $.get(server_address+'/subject_attendence/'+fuid, function(subject_attendence){
        if(subject_attendence['data'] instanceof Object){
            self.subject_attendence = subject_attendence['data']
        }
        else{
            self.subject_attendence = JSON.parse(subject_attendence['data'])
        }
        callback()
    })
}
AttendenceView.prototype.init = function(){
    var self = this
    this.get_data_from_server(function(){
        self.create_base_template()
        self.populate_attendence()
        self.init_click_handlers()
    })
}
AttendenceView.prototype.populate_attendence = function(){
    var percentColors = [
        { pct: 0.0, color: { r: 0xff, g: 0x00, b: 0 } },
        { pct: 0.5, color: { r: 0xff, g: 0xff, b: 0 } },
        { pct: 1.0, color: { r: 0x00, g: 0xff, b: 0 } } ];
    // for( var i=0,len=this.subject_attendence.length ; i<len ; i++ ){
    for( item in this.subject_attendence ){
        var att_val = (this.subject_attendence[item].attended/this.subject_attendence[item].total)*100
        $('#attendence-'+item+'>.att').easyPieChart({
            size: 120,
            barColor: function(pct){
                pct = pct/100
                for (var i = 1; i < percentColors.length - 1; i++) {
                    if (pct < percentColors[i].pct) {
                        break;
                    }
                }
                var lower = percentColors[i - 1];
                var upper = percentColors[i];
                var range = upper.pct - lower.pct;
                var rangePct = (pct - lower.pct) / range;
                var pctLower = 1 - rangePct;
                var pctUpper = rangePct;
                var color = {
                    r: Math.floor(lower.color.r * pctLower + upper.color.r * pctUpper),
                    g: Math.floor(lower.color.g * pctLower + upper.color.g * pctUpper),
                    b: Math.floor(lower.color.b * pctLower + upper.color.b * pctUpper)
                };
                hexcol = "#" +
                 ("0" + parseInt(color.r,10).toString(16)).slice(-2) +
                 ("0" + parseInt(color.g,10).toString(16)).slice(-2) +
                 ("0" + parseInt(color.b,10).toString(16)).slice(-2)
                return hexcol
            }
        }).data('easyPieChart').update(att_val);
    }
}
AttendenceView.prototype.create_base_template = function(){
    htmlstr =
        '
'+
            'Attendence'+
        '
'+
        '
'
    for(item in this.subject_attendence){
        htmlstr += '
'+
            '

'+
            '
'+item+' ('+this.subject_attendence[item].attended+'/'+this.subject_attendence[item].total+')
'+
            '
+attended
'+
            '
+bunked
'+
        '
'
    }
    htmlstr += '
'
    $('#mcontent').html(htmlstr);
}
AttendenceView.prototype.update_attendence = function(){
    for( item in this.subject_attendence ){
        att_el = $('.att-name[data-subject='+ item +']')[0]
        $(att_el).text(item+' ('+this.subject_attendence[item].attended+'/'+this.subject_attendence[item].total+')')
        att_pie = $('.att[data-subject='+ item +']')[0]
        var att_val = (this.subject_attendence[item].attended/this.subject_attendence[item].total)*100
        $(att_pie).easyPieChart({}).data('easyPieChart').update(att_val)
        if( this.subject_attendence[item].total == 1 )  // Don't know what exactly is happending but it was not updating
            $(att_pie).easyPieChart({}).data('easyPieChart').update(att_val)
    }
    post_data = {
        'id': fuid,
        'attendance': JSON.stringify(this.subject_attendence)
    }
    post_data = JSON.stringify(post_data)
    $.post(server_address+'/update_attendence/', {'data':post_data} ,  function(data){
        console.log('Attendance updated in server')
    })
    }
AttendenceView.prototype.init_click_handlers = function(){
    var self = this
    $('.att-att').click(function(){
        sub = $(this).data('subject')
        self.subject_attendence[sub].attended += 1
        self.subject_attendence[sub].total += 1
        self.update_attendence()
    })
    $('.att-bnk').click(function(){
        sub = $(this).data('subject')
        self.subject_attendence[sub].total += 1
        self.update_attendence()
    })
}

CalenderView = function() {
    this.name = 'calenderView';
}
CalenderView.prototype.get_data_from_server = function(callback){
    var self = this;
    if (callback === undefined) { callback=function(){} }
    $.get(server_address+'/calendar/'+fuid, function(cal_events){
        self.cal_events = JSON.parse(cal_events)
        for(item in self.cal_events){
            i = {
                'title': self.cal_events[item]['description']+'('+self.cal_events[item]['to']+')',
                'start': self.cal_events[item]['due']
                },
            self.cal_events[item] = i
        }
        callback()
    })
}
CalenderView.prototype.init = function(){
    var self = this
    this.get_data_from_server(function(){
        self.create_base_template()
        self.populate_calender()
    })
}
CalenderView.prototype.populate_calender = function(){
    $('#calender-view-data').fullCalendar({
        header: {
            // not really happending, probably need paid version
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        events: this.cal_events
    });
}
CalenderView.prototype.create_base_template = function(){
    htmlstr =
        '
'+
            'Calender'+
        '
'+
        '
'+
        '
'
    $('#mcontent').html(htmlstr);
}

AboutView = function() {
    this.name = 'aboutView';
}
AboutView.prototype.init = function(){
    this.create_base_template()
    this.populate_about_content()
}
AboutView.prototype.populate_about_content = function(){
    htmlstr = ''
    htmlstr +=
        '
'+
            ''+
        '
'+
        '
'+
            'Team'+
        '
'+
        '
'+
            '
'+
            'Team Bridge'+
        '
'+
        '
'+
            'Team Members'+
        '
'+
        '
'+
            '
'+
            '😜 Aayisha Shehsin 😜
'+
            'Yeah, it was hard getting her up and running'+
            '
'+
            '
'+
            '🤔 Abhai Kollara 🤔
'+
            "I asked him to submit and tagline and he didn't"+
            '
'+
            '
'+
            '✌ Abin Simon ✌
'+
            'I need help, seriously!'
        '
'
    $('#about-view-data').html(htmlstr);
}
AboutView.prototype.create_base_template = function(){
    htmlstr =
        '
'+
            'About'+
        '
'+
        '
'+
        '
'
    $('#mcontent').html(htmlstr);
}

// User login
function onSignIn(googleUser) {
    var profile = googleUser.getBasicProfile();
    user_data['id'] = profile.getId();
    user_data['name'] = profile.getName();
    user_data['email'] = profile.getEmail();
    user_data['photo'] = profile.getImageUrl();
    console.log(user_data);
    fuid = user_data['id']
    $.post(server_address+'/signin/', { data:JSON.stringify(user_data) } ,  function(data){
        // populate_user_profile(user_data);
        data = JSON.parse(data)
        if(data['exists'] == true){
            initialize_user = new InitializeUser(user_data);
            initialize_user.init();
            home = new Home();
            home.init();
            $('#login-popup').css('display', 'none');
        }
        else{
            // Show class selector
            classes = data['options']
            htmlstr = ''
            for(i=0,len=classes.length;i<len;i++){
                htmlstr+='
'+classes[i]+'
'
            }
            $('#popup-class-list').html(htmlstr)
            class_option_buttons = $('.class-option')
            for( var i=0,len=class_option_buttons.length; i<len; i++ ){
                $(class_option_buttons[i]).click(function(){
                    user_class = $(this).data('class').replace('%',' ')
                    $.post(server_address+'/create_user/', { 'user_data':JSON.stringify(user_data), 'class':user_class } ,  function(data){
                        console.log('New user created')
                        $($('#choose-class-popup').parent()).css('display', 'none');
                        $('#login-popup').css('display', 'none');
                        fuid = user_data['id']
                        initialize_user = new InitializeUser(user_data);
                        initialize_user.init();
                        home = new Home();
                        home.init();
                    })
                    })
            }
            $('#popup-welcome-message').text('Hello '+user_data['name']+' , welcome to Bridge!')
            $($('#choose-class-popup').parent()).css('display', 'flex');
        }
    })
}

// Hamburger menu thingy
$('#hamburger-menu-button').click(function(e){
    e.stopPropagation();
    nav = $($('.leftpane')[0]);
    nav.css('position', 'absolute');
    nav.css('display', 'block');
    nav.css('width', '50%');
    // nav.css('visibility', 'visible');
    // $($('.midpane')[0]).css('width', '50%');
});

$('div').not('.leftpane').click(function(){
    cur_state = $('#hamburger-menu-button').css('display');  //Kinda hacky, eeks
    if(cur_state == 'block'){
        nav = $($('.leftpane')[0]);
        nav.css('display', 'none');
        nav.css('width', '20vw');
        // nav.css('visibility', 'hidden');
        // $($('.midpane')[0]).css('width', 'calc(100vw - 45px)');
    }
});

$('#upcoming-menu-button').click(function(e){
    e.stopPropagation();
    nav = $($('.rightpane')[0]);
    nav.css('position', 'absolute');
    nav.css('display', 'block');
    nav.css('width', '50%');
    nav.css('right', '0');
    // nav.css('visibility', 'visible');
    // $($('.midpane')[0]).css('width', '50%');
});

$('div').not('.rightpane').click(function(){
    cur_state = $('#upcoming-menu-button').css('display');  //Kinda hacky, eeks
    if(cur_state == 'block'){
        nav = $($('.rightpane')[0]);
        nav.css('display', 'none');
        nav.css('width', '20vw');
        // nav.css('visibility', 'hidden');
        // $($('.midpane')[0]).css('width', 'calc(100vw - 45px)');
    }
});


text:
<!DOCTYPE html>

<html lang="se">

    <head>
        {% block head %}

        <meta http-equiv="refresh" content="{{ refresh_time }}" />

        <script type="text/javascript" src="{{ url_for('static', filename='DataTables-1.10.15/js/jquery.js') }}"></script>
        <script type="text/javascript" src="{{ url_for('static', filename='DataTables-1.10.15/js/jquery.dataTables.min.js') }}"></script>
        <script type="text/javascript" src="{{ url_for('static', filename='js/main.js') }}"></script>

        <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='DataTables-1.10.15/css/jquery.dataTables.min.css') }}">
        <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
        <title>{{ title }} - Wellstep Parser</title>

        {% endblock %}
    </head>

    <body>

        {% block body %}{% endblock %}

        <div class="footer">
            {% block footer %}
            © 2017 - Daniel Falk
            {% endblock %}
        </div>

    </body>

</html>

redpajama_set_name: RedPajamaGithub


text:
package no.asgari.civilization.server.resource;

import no.asgari.civilization.server.model.PBF;
import no.asgari.civilization.server.mongodb.AbstractCivilizationTest;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.Test;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import static org.assertj.core.api.Assertions.assertThat;

public class AdminResourceTest extends AbstractCivilizationTest {
    protected static String BASE_URL = String.format("http://localhost:%d/api", RULE.getLocalPort());

    @Test
    public void adminCanChangeUser() {
        PBF pbf = getApp().pbfCollection.findOne();

        Response response = client().target(UriBuilder.fromPath(BASE_URL + "/admin/changeuser").build())
                .queryParam("gameid", pbf.getId())
                .queryParam("fromUsername", "Itchi")
                .queryParam("toUsername", "DaveLuca")
                .request()
                .header(HttpHeaders.AUTHORIZATION, getAdminEncoded())
                .post(null);

        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);

        pbf = getApp().pbfCollection.findOne();
        long count = pbf.getPlayers().stream().filter(p -> p.getUsername().equals("DaveLuca")).count();
        assertThat(count).isEqualTo(1L);
    }

    @Test
    public void cleanup() {
        Response response = client().target(UriBuilder.fromPath(BASE_URL + "/admin/cleanup").build())
                .request()
                .header(HttpHeaders.AUTHORIZATION, getAdminEncoded())
                .post(null);
        assertThat(response.getStatus()).isEqualTo(HttpStatus.NO_CONTENT_204);
    }
}


text:
#ifndef BLE_SERIALIZATION_H__
#define BLE_SERIALIZATION_H__

#include "nordic_common.h"
#include "nrf_error.h"
#include <stdint.h>
#include <stddef.h>

/**@brief The types of serialization packets. */
typedef enum
{
    SER_PKT_TYPE_CMD = 0,     /**< Command packet type. */
    SER_PKT_TYPE_RESP,        /**< Command Response packet type. */
    SER_PKT_TYPE_EVT,         /**< Event packet type. */
    SER_PKT_TYPE_DTM_CMD,     /**< DTM Command packet type. */
    SER_PKT_TYPE_DTM_RESP,    /**< DTM Response packet type. */
    SER_PKT_TYPE_MAX          /**< Upper bound. */
} ser_pkt_type_t;

#define  LOW16(a) ((uint16_t)((a & 0x0000FFFF) >> 0))
#define HIGH16(a) ((uint16_t)((a & 0xFFFF0000) >> 16))

//lint -esym(516,__INTADDR__) Symbol '__INTADDR__()' has arg. type conflict
//lint -esym(628,__INTADDR__) no argument information provided for function '__INTADDR__()'

/** Size in bytes of the Error Code field in a Command Response packet. */
#define SER_ERR_CODE_SIZE              4
/** Size in bytes of the Packet Type field (@ref ser_pkt_type_t). */
#define SER_PKT_TYPE_SIZE              1
/** Size in bytes of the Operation Code field. */
#define SER_OP_CODE_SIZE               1

/** Position of the Packet Type field in a serialized packet buffer. */
#define SER_PKT_TYPE_POS               0
/** Position of the Operation Code field in a serialized packet buffer. */
#define SER_PKT_OP_CODE_POS            (SER_PKT_TYPE_SIZE)
/** Position of the Data in a serialized packet buffer. */
#define SER_PKT_DATA_POS               (SER_PKT_TYPE_SIZE + SER_OP_CODE_SIZE)

/** Position of the Operation Code field in a command buffer. */
#define SER_CMD_OP_CODE_POS            0
/** Position of the Data in a command buffer.*/
#define SER_CMD_DATA_POS               (SER_OP_CODE_SIZE)
/** Size of the Command header. */
#define SER_CMD_HEADER_SIZE            (SER_OP_CODE_SIZE)
/** Size of the Command Response header. */
#define SER_CMD_RSP_HEADER_SIZE        (SER_OP_CODE_SIZE + SER_ERR_CODE_SIZE)
/** Position of the Command Response code. */
#define SER_CMD_RSP_STATUS_CODE_POS    (SER_OP_CODE_SIZE)

/** Size of event ID field. */
#define SER_EVT_ID_SIZE                2
/** Position of event ID field. */
#define SER_EVT_ID_POS                 0
/** Size of event header. */
#define SER_EVT_HEADER_SIZE            (SER_EVT_ID_SIZE)
/** Size of event connection handler. */
#define SER_EVT_CONN_HANDLE_SIZE       2

/** Position of the Op Code in the DTM command buffer.*/
#define SER_DTM_CMD_OP_CODE_POS        0
/** Position of the data in the DTM command buffer.*/
#define SER_DTM_CMD_DATA_POS           1

/** Position of the Op Code in the DTM command response buffer.*/
#define SER_DTM_RESP_OP_CODE_POS       1
/** Position of the status field in the DTM command response buffer.*/
#define SER_DTM_RESP_STATUS_POS        2

/** Value to indicate that an optional field is encoded in the serialized packet, e.g. white list.*/
#define SER_FIELD_PRESENT              0x01
/** Value to indicate that an optional field is not encoded in the serialized packet. */
#define SER_FIELD_NOT_PRESENT          0x00

/** Enable SER_ASSERT<*> assserts */
#define SER_ASSERTS_ENABLED 1

/** Returns with error code if expr is not true. It is used for checking error which should be
 * checked even when SER_ASSERTS_ENABLED is not set. */
#define SER_ERROR_CHECK(expr, error_code) do { if (!(expr)) return (error_code); } while (0)

#ifdef SER_ASSERTS_ENABLED
/** Returns with error code if expr is not true. */
#define SER_ASSERT(expr, error_code) SER_ERROR_CHECK(expr, error_code)
/** Returns with  if expr is not true. */
#define SER_ASSERT_VOID_RETURN(expr) do { if (!(expr)) return; } while (0)
/** Returns with  \ref NRF_ERROR_INVALID_LENGTH if len is not less or equal to maxlen. */
#define SER_ASSERT_LENGTH_LEQ(len, maxlen) \
    SER_ASSERT((len) <= (maxlen), NRF_ERROR_INVALID_LENGTH)
/** Returns with  \ref NRF_ERROR_INVALID_LENGTH if actual_len is not equal to expected_len. */
#define SER_ASSERT_LENGTH_EQ(actual_len, expected_len) \
    SER_ASSERT((actual_len) == (expected_len), NRF_ERROR_INVALID_LENGTH)
/** Returns with  \ref NRF_ERROR_NULL if pointer is null. */
#define SER_ASSERT_NOT_NULL(ptr) SER_ASSERT((ptr) != NULL, NRF_ERROR_NULL)
#else
#define SER_ASSERT(expr, error_code)
#define SER_ASSERT_VOID_RETURN(expr)
#define SER_ASSERT_LENGTH_LEQ(len, maxlen) UNUSED_VARIABLE(maxlen)
#define SER_ASSERT_LENGTH_EQ(actual_len, expected_len)
#define SER_ASSERT_NOT_NULL(ptr)
#endif

/** Maximum length of p_value in \ref ble_gattc_write_params_t. See Bluetooth 4.0 spec: 3.4.5.1 and
 *  3.4.5.3. */
#define BLE_GATTC_WRITE_P_VALUE_LEN_MAX    (GATT_MTU_SIZE_DEFAULT - 3)

/** See Bluetooth 4.0 spec: 3.4.4.7. */
#define BLE_GATTC_HANDLE_COUNT_LEN_MAX     ((GATT_MTU_SIZE_DEFAULT - 1) / 2)

/** Generic command response status code encoder. */
uint32_t ser_ble_cmd_rsp_status_code_enc(uint8_t          op_code,
                                         uint32_t         command_status,
                                         uint8_t * const  p_buf,
                                         uint32_t * const p_buf_len);

/** Generic command response result code decoder. */
uint32_t ser_ble_cmd_rsp_result_code_dec(uint8_t const * const p_buf,
                                         uint32_t * const      p_pos,
                                         uint32_t              packet_len,
                                         uint8_t               op_code,
                                         uint32_t * const      p_result_code);

/** Generic command response decoder. */
uint32_t ser_ble_cmd_rsp_dec(uint8_t const * const p_buf,
                             uint32_t              packet_len,
                             uint8_t               op_code,
                             uint32_t * const      p_result_code);

/**@brief Function for safe encoding an uint16 value.
 *
 * Safe decoding of an uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_field          Uint16 value to be encoded.
 * @param[out]     p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint16 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t uint16_t_enc(const void * const p_field,
                      uint8_t * const    p_buf,
                      uint32_t           buf_len,
                      uint32_t * const   p_index);

/**@brief Function for safe decoding an uint16 value.
 *
 * Safe decoding of an uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint16 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     p_field          Pointer to the location where uint16 value will be decoded.
 */
uint32_t uint16_t_dec(uint8_t const * const p_buf,
                      uint32_t              buf_len,
                      uint32_t * const      p_index,
                      void *                p_field);

/**@brief Function for safe decoding an uint16 value.
 *
 * Safe decoding of an uint16 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  index            \c in: Index to start of uint16 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     value            Decoded uint16 value.
 */
void uint16_dec(uint8_t const * const p_buf,
                uint32_t              packet_len,
                uint32_t * const      index,
                uint16_t * const      value);

/**@brief Function for safe encoding an uint18 value.
 *
 * Safe decoding of an uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index            \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     p_field          Pointer to uint8 value to be encoded.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t uint8_t_enc(const void * const p_field,
                     uint8_t * const    p_buf,
                     uint32_t           buf_len,
                     uint32_t * const   p_index);

/**@brief Function for safe decoding an uint8 value.
 *
 * Safe decoding of an uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     p_field          Pointer to the location for decoded uint8 value.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t uint8_t_dec(uint8_t const * const p_buf,
                     uint32_t              buf_len,
                     uint32_t * const      p_index,
                     void *                p_field);

/**@brief Function for safe decoding an uint8 value.
 *
 * Safe decoding of an uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  index            \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     value            Decoded uint8 value.
 */
void uint8_dec(uint8_t const * const p_buf,
               uint32_t              packet_len,
               uint32_t * const      index,
               uint8_t * const       value);

/**@brief Function for safe decoding an uint18 value.
 *
 * Safe decoding of an uint8 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  index            \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     value            Decoded uint8 value.
 */
void int8_dec(uint8_t const * const p_buf,
              uint32_t              packet_len,
              uint32_t * const      index,
              int8_t * const        value);

/**@brief Function for safe encoding variable length field encoded as length(8bit)+data.
 *
 * Safe encoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[out]     p_data           Pointer to data to encode.
 * @param[in]      dlen             Length of data to encode (0-255).
 * @param[out]     p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t len8data_enc(uint8_t const * const p_data,
                      uint8_t const         dlen,
                      uint8_t * const       p_buf,
                      uint32_t              buf_len,
                      uint32_t * const      p_index);

/**@brief Function for safe decoding variable length field encoded as length(8bit)+data.
 *
 * Safe decoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     pp_data          Pointer to pointer to decoded data (p_data is set to NULL in
 *                                  case data is not present in the buffer).
 * @param[out]     p_len            Decoded length (0-255).
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t len8data_dec(uint8_t const * const p_buf,
                      uint32_t              buf_len,
                      uint32_t * const      p_index,
                      uint8_t * * const     pp_data,
                      uint8_t * const       p_len);

/**@brief Function for safe encoding variable length field encoded as length(16bit)+data.
 *
 * Safe encoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * It is possible that provided p_data is NULL in that case length is encoded and it's followed by
 * SER_FIELD_NOT_PRESENT flag. SER_FIELD_PRESENT flag preceeds data otherwise.
 *
 * @param[in]      p_data           Data to encode.
 * @param[in]      dlen             Input data length (16bit).
 * @param[in]      p_buf            Pointer to the beginning of the output buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the encoded data.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t len16data_enc(uint8_t const * const p_data,
                       uint16_t const        dlen,
                       uint8_t * const       p_buf,
                       uint32_t              buf_len,
                       uint32_t * const      p_index);

/**@brief Function for safe decoding variable length field encoded as length(16bit)+data.
 *
 * Safe decoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * Encoded data consist of length field, presence flag and conditional data (present only is presence flag
 * is set). p_data pointer is required to be not NULL only is presence flag is set.
 *
 * @param[in]      p_buf            Pointer to the beginning of the input buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded data.
 * @param[in]      pp_data          Pointer to pointer to decoded data.
 * @param[in]      p_dlen             data length (16bit).
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t len16data_dec(uint8_t const * const p_buf,
                       uint32_t              buf_len,
                       uint32_t * const      p_index,
                       uint8_t * * const     pp_data,
                       uint16_t * const      p_dlen);

/**@brief Function for safe encoding of uint16 table with a given element count.
 *
 * Safe encoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * It is possible that provided p_data is NULL in that case length is encoded and it's followed by
 * SER_FIELD_NOT_PRESENT flag. SER_FIELD_PRESENT flag precedes data otherwise.
 *
 * @param[in]      p_data           Data table to encode.
 * @param[in]      count            Table element count.
 * @param[in]      p_buf            Pointer to the beginning of the output buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the encoded data.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */

uint32_t count16_cond_data16_enc(uint16_t const * const p_data,
                                 uint16_t const         count,
                                 uint8_t * const        p_buf,
                                 uint32_t               buf_len,
                                 uint32_t * const       p_index);

/**@brief Function for safe decoding of uint16 table with a given element count.
 *
 * Safe encoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * It is possible that provided p_data is NULL in that case length is encoded and it's followed by
 * SER_FIELD_NOT_PRESENT flag. SER_FIELD_PRESENT flag precedes data otherwise.
 *
 * @param[in]      p_buf            Pointer to the beginning of the output buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the encoded data.
 * @param[in]      pp_data           Pointer to pointer to the table to encode.
 * @param[in,out]  p_count           Pointer to table element count - initialised with max count
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 * @retval NRF_ERROR_DATA_SIZE      Decoding failure. Initial count is smaller than actual.
 */

uint32_t count16_cond_data16_dec(uint8_t const * const p_buf,
                                 uint32_t              buf_len,
                                 uint32_t * const      p_index,
                                 uint16_t * * const    pp_data,
                                 uint16_t * const      p_count);

/**@brief Function for safe decoding of variable length field encoded as length(16bit)+data.
 *
 * Safe decoding of an variable length field. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * Encoded data consist of presence flag, optional length field, second presence flag and optional data.
 *
 *
 * @param[in]      p_buf            Pointer to the beginning of the input buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded data.
 * @param[out]     pp_data           Pointer to decoded data.
 * @param[out]     pp_len            data length (16bit).
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */

uint32_t cond_len16_cond_data_dec(uint8_t const * const p_buf,
                                  uint32_t              buf_len,
                                  uint32_t * const      p_index,
                                  uint8_t * * const     pp_data,
                                  uint16_t * * const    pp_len);

/**@brief Command response encoder - replacement of - ser_ble_cmd_rsp_status_code_enc
 * with layout aligned to the rest of encoder functions
 *
 * @param[in]      op_code          Operation code - see BLE_GAP_SVCS
 * @param[in]      return_code      nRF Error Code.
 * @param[in]      p_buff           pointer to the start of pointer to decoded data.
 * @param[in,out]  p_buff_len       \c in: size of buffer
 *                                  \c out: used bytes in buffer
 * @param[in,out]  p_buff_len       \c in: initial offset in buffer
 *                                  \c out: final offset in buffer
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 * @retval NRF_ERROR_NULL           Invalid pointer
 */
uint32_t op_status_enc(uint8_t          op_code,
                       uint32_t         return_code,
                       uint8_t * const  p_buff,
                       uint32_t * const p_buff_len,
                       uint32_t * const p_index);

/**@brief command response encoder with conditional 16bit field
 *
 * @param[in]      op_code          Operation code - see BLE_GAP_SVCS
 * @param[in]      return_code      nRF Error Code.
 * @param[in]      value            optional 16bit field encoded for return code == NRF_SUCCESS
 * @param[in]      p_buff           pointer to the start of pointer to decoded data.
 * @param[in,out]  p_buff_len       \c in: size of buffer
 *                                  \c out: used bytes in buffer
 * @param[in,out]  p_buff_len       \c in: initial offset in buffer
 *                                  \c out: final offset in buffer
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 * @retval NRF_ERROR_NULL           Invalid pointer
 */

uint32_t op_status_cond_uint16_enc(uint8_t          op_code,
                                   uint32_t         return_code,
                                   uint16_t         value,
                                   uint8_t * const  p_buff,
                                   uint32_t * const p_buff_len,
                                   uint32_t * const p_index);

/**@brief Function for safe encoding a buffer of known size.
 *
 * Safe encoding of a buffer. Encoder assumes that size is known to the decoder and it is not
 * encoded here. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_data           Data to encode.
 * @param[in]      dlen             Input data length (16bit).
 * @param[in]      p_buf            Pointer to the beginning of the output buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the encoded data.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t buf_enc(uint8_t const * const p_data,
                 uint16_t const        dlen,
                 uint8_t * const       p_buf,
                 uint32_t              buf_len,
                 uint32_t * const      p_index);

/**@brief Function for safe decoding a buffer of known size.
 *
 * Safe decoding of buffer of known size. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 * Encoded data consist of presence flag and conditional data (present only is presence flag
 * is set). p_data pointer is required to be not NULL only is presence flag is set. Length is provided
 * as an input to the function.
 *
 * @param[in]      p_buf            Pointer to the beginning of the input buffer.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint8 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded data.
 * @param[in]      pp_data          Pointer to pointer to decoded data.
 * @param[in]      data_len         Length of buffer for decoded data (16bit).
 * @param[in]      dlen             Length of data to decode (16bit).
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t buf_dec(uint8_t const * const p_buf,
                 uint32_t              buf_len,
                 uint32_t * const      p_index,
                 uint8_t * * const     pp_data,
                 uint16_t              data_len,
                 uint16_t              dlen);

/**@brief Function for safe encoding an uint32 value.
 *
 * Safe decoding of an uint32 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_field          uint32 value to be encoded.
 * @param[out]     p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint32 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 *
 * @return NRF_SUCCESS              Fields decoded successfully.
 * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
 */
uint32_t uint32_t_enc(void const * const p_field,
                      uint8_t * const    p_buf,
                      uint32_t           buf_len,
                      uint32_t * const   p_index);

/**@brief Function for safe decoding an uint32 value.
 *
 * Safe decoding of an uint32 value. Range checks will be done if @ref SER_ASSERTS_ENABLED is set.
 *
 * @param[in]      p_buf            Buffer containing the value.
 * @param[in]      buf_len          Size of buffer.
 * @param[in,out]  p_index          \c in: Index to start of uint32 value in buffer.
 *                                  \c out: Index in buffer to first byte after the decoded value.
 * @param[out]     value            Decoded uint32 value.
 */
uint32_t uint32_t_dec(uint8_t const * const p_buf,
                      uint32_t              buf_len,
                      uint32_t * const      p_index,
                      void *                p_field);

#endif


text:
---
uid: SolidEdgeFrameworkSupport.Dimension.RadialExtensionDistance
summary:
remarks:
---


text:
#include "webrtc/modules/audio_device/include/audio_device.h"

namespace webrtc {

class FakeAudioDeviceModule : public AudioDeviceModule {
 public:
  FakeAudioDeviceModule() {}
  virtual ~FakeAudioDeviceModule() {}
  virtual int32_t AddRef() const { return 0; }
  virtual int32_t Release() const { return 0; }
  virtual int32_t RegisterEventObserver(AudioDeviceObserver* eventCallback) {
    return 0;
  }
  virtual int32_t RegisterAudioCallback(AudioTransport* audioCallback) {
    return 0;
  }
  virtual int32_t Init() { return 0; }
  virtual int32_t InitSpeaker() { return 0; }
  virtual int32_t SetPlayoutDevice(uint16_t index) { return 0; }
  virtual int32_t SetPlayoutDevice(WindowsDeviceType device) { return 0; }
  virtual int32_t SetStereoPlayout(bool enable) { return 0; }
  virtual int32_t StopPlayout() { return 0; }
  virtual int32_t InitMicrophone() { return 0; }
  virtual int32_t SetRecordingDevice(uint16_t index) { return 0; }
  virtual int32_t SetRecordingDevice(WindowsDeviceType device) { return 0; }
  virtual int32_t SetStereoRecording(bool enable) { return 0; }
  virtual int32_t SetAGC(bool enable) { return 0; }
  virtual int32_t StopRecording() { return 0; }
  virtual int64_t TimeUntilNextProcess() { return 0; }
  virtual int32_t Process() { return 0; }
  virtual int32_t Terminate() { return 0; }

  virtual int32_t ActiveAudioLayer(AudioLayer* audioLayer) const { return 0; }
  virtual ErrorCode LastError() const { return kAdmErrNone; }
  virtual bool Initialized() const { return true; }
  virtual int16_t PlayoutDevices() { return 0; }
  virtual int16_t RecordingDevices() { return 0; }
  virtual int32_t PlayoutDeviceName(uint16_t index,
                            char name[kAdmMaxDeviceNameSize],
                            char guid[kAdmMaxGuidSize]) {
    return 0;
  }
  virtual int32_t RecordingDeviceName(uint16_t index,
                              char name[kAdmMaxDeviceNameSize],
                              char guid[kAdmMaxGuidSize]) {
    return 0;
  }
  virtual int32_t PlayoutIsAvailable(bool* available) { return 0; }
  virtual int32_t InitPlayout() { return 0; }
  virtual bool PlayoutIsInitialized() const { return true; }
  virtual int32_t RecordingIsAvailable(bool* available) { return 0; }
  virtual int32_t InitRecording() { return 0; }
  virtual bool RecordingIsInitialized() const { return true; }
  virtual int32_t StartPlayout() { return 0; }
  virtual bool Playing() const { return false; }
  virtual int32_t StartRecording() { return 0; }
  virtual bool Recording() const { return false; }
  virtual bool AGC() const { return true; }
  virtual int32_t SetWaveOutVolume(uint16_t volumeLeft,
                           uint16_t volumeRight) {
    return 0;
  }
  virtual int32_t WaveOutVolume(uint16_t* volumeLeft,
                        uint16_t* volumeRight) const {
    return 0;
  }
  virtual bool SpeakerIsInitialized() const { return true; }
  virtual bool MicrophoneIsInitialized() const { return true; }
  virtual int32_t SpeakerVolumeIsAvailable(bool* available) { return 0; }
  virtual int32_t SetSpeakerVolume(uint32_t volume) { return 0; }
  virtual int32_t SpeakerVolume(uint32_t* volume) const { return 0; }
  virtual int32_t MaxSpeakerVolume(uint32_t* maxVolume) const { return 0; }
  virtual int32_t MinSpeakerVolume(uint32_t* minVolume) const { return 0; }
  virtual int32_t SpeakerVolumeStepSize(uint16_t* stepSize) const { return 0; }
  virtual int32_t MicrophoneVolumeIsAvailable(bool* available) { return 0; }
  virtual int32_t SetMicrophoneVolume(uint32_t volume) { return 0; }
  virtual int32_t MicrophoneVolume(uint32_t* volume) const { return 0; }
  virtual int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const { return 0; }
  virtual int32_t MinMicrophoneVolume(uint32_t* minVolume) const { return 0; }
  virtual int32_t MicrophoneVolumeStepSize(uint16_t* stepSize) const {
    return 0;
  }
  virtual int32_t SpeakerMuteIsAvailable(bool* available) { return 0; }
  virtual int32_t SetSpeakerMute(bool enable) { return 0; }
  virtual int32_t SpeakerMute(bool* enabled) const { return 0; }
  virtual int32_t MicrophoneMuteIsAvailable(bool* available) { return 0; }
  virtual int32_t SetMicrophoneMute(bool enable) { return 0; }
  virtual int32_t MicrophoneMute(bool* enabled) const { return 0; }
  virtual int32_t MicrophoneBoostIsAvailable(bool* available) { return 0; }
  virtual int32_t SetMicrophoneBoost(bool enable) { return 0; }
  virtual int32_t MicrophoneBoost(bool* enabled) const { return 0; }
  virtual int32_t StereoPlayoutIsAvailable(bool* available) const {
    *available = false;
    return 0;
  }
  virtual int32_t StereoPlayout(bool* enabled) const { return 0; }
  virtual int32_t StereoRecordingIsAvailable(bool* available) const {
    *available = false;
    return 0;
  }
  virtual int32_t StereoRecording(bool* enabled) const { return 0; }
  virtual int32_t SetRecordingChannel(const ChannelType channel) { return 0; }
  virtual int32_t RecordingChannel(ChannelType* channel) const { return 0; }
  virtual int32_t SetPlayoutBuffer(const BufferType type,
                           uint16_t sizeMS = 0) {
    return 0;
  }
  virtual int32_t PlayoutBuffer(BufferType* type, uint16_t* sizeMS) const {
    return 0;
  }
  virtual int32_t PlayoutDelay(uint16_t* delayMS) const { return 0; }
  virtual int32_t RecordingDelay(uint16_t* delayMS) const { return 0; }
  virtual int32_t CPULoad(uint16_t* load) const { return 0; }
  virtual int32_t StartRawOutputFileRecording(
      const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
    return 0;
  }
  virtual int32_t StopRawOutputFileRecording() { return 0; }
  virtual int32_t StartRawInputFileRecording(
      const char pcmFileNameUTF8[kAdmMaxFileNameSize]) {
    return 0;
  }
  virtual int32_t StopRawInputFileRecording() { return 0; }
  virtual int32_t SetRecordingSampleRate(const uint32_t samplesPerSec) {
    return 0;
  }
  virtual int32_t RecordingSampleRate(uint32_t* samplesPerSec) const {
    return 0;
  }
  virtual int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) {
    return 0;
  }
  virtual int32_t PlayoutSampleRate(uint32_t* samplesPerSec) const { return 0; }
  virtual int32_t ResetAudioDevice() { return 0; }
  virtual int32_t SetLoudspeakerStatus(bool enable) { return 0; }
  virtual int32_t GetLoudspeakerStatus(bool* enabled) const { return 0; }
  virtual bool BuiltInAECIsAvailable() const { return false; }
  virtual int32_t EnableBuiltInAEC(bool enable) { return -1; }
  virtual bool BuiltInAECIsEnabled() const { return false; }
  virtual bool BuiltInAGCIsAvailable() const { return false; }
  virtual int32_t EnableBuiltInAGC(bool enable) { return -1; }
  virtual bool BuiltInNSIsAvailable() const { return false; }
  virtual int32_t EnableBuiltInNS(bool enable) { return -1; }
};

}  // namespace webrtc


text:
package test.area;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name="areas",urlPatterns={"/areajson"})
@MultipartConfig
public class AreaServlet extends HttpServlet{

	 public void doGet(HttpServletRequest request,
	            HttpServletResponse response) throws ServletException, IOException {
		 	response.setContentType("text/xml;charset=utf-8");
	        AreaBo bo=new AreaBo();

	        String pString=request.getParameter("input");
	        pString=new String(pString.getBytes("iso-8859-1"),"UTF-8");
	        pString=pString.toLowerCase();

	        String stype=request.getParameter("stype");

	        String sql="";
	        if(stype!=null&&"country".equals(stype)){
				sql="select a.id as id,a.name as name,a.fullname as fullname,a.ename as ename,a.pyname as pyname,a.shortname as shortname,p.name as pnameStr,p.ename as penameStr,e.name as stypeStr,e.ename as stypeeStr "
						+"from area a "
						+"left join enums p on  a.pid = p.id "
						+"left join enums e on a.stype = e.id "
						+"where "
						+"1=1 and a.stype = 'country' "
						+"and (a.name like '"+pString+"%' or a.fullname like '"+pString+"%' or a.ename like '"+pString+"%' or a.pyname like '"+pString+"%' or a.shortname like '"+pString+"%')";
			}
	        if(stype!=null&&"city".equals(stype)){
				sql="select a.id as id,a.name as name,a.fullname as fullname,a.ename as ename,a.pyname as pyname,a.shortname as shortname,p.name as pnameStr,p.ename as penameStr,e.name as stypeStr,e.ename as stypeeStr "
						+"from area a "
						+"left join area p on  a.pid = p.id "
						+"left join enums e on a.stype = e.id "
						+"where "
						+"1=1 and a.stype = 'city' "
						+"and (a.name like '"+pString+"%' or a.fullname like '"+pString+"%' or a.ename like '"+pString+"%' or a.pyname like '"+pString+"%' or a.shortname like '"+pString+"%')";
			}
	        if(stype!=null&&"all".equals(stype)){
				sql="select a.id as id,a.name as name,a.fullname as fullname,a.ename as ename,a.pyname as pyname,a.shortname as shortname,p.name as pnameStr,p.ename as penameStr,e.name as stypeStr,e.ename as stypeeStr "
						+"from area a "
						+"left join area p on  a.pid = p.id "
						+"left join enums e on a.stype = e.id "
						+"where "
						+"1=1 "
						+"and (a.name like '"+pString+"%' or a.fullname like '"+pString+"%' or a.ename like '"+pString+"%' or a.pyname like '"+pString+"%' or a.shortname like '"+pString+"%')";
			}

			List<AreaModel> list=new ArrayList<AreaModel>();
			try {
				list = bo.customListModel(new String[]{sql});
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			List<AreaJsonModel> jslist=new ArrayList<AreaJsonModel>();
			String xml="<?xml version=\"1.0\" encoding=\"utf-8\" ?><results>";
			for(AreaModel area:list){
				xml+="<rs id=\""+area.getId()+"\" latlng=\""+(area.getLat()+","+area.getLng())+"\" info=\"\">"+(area.getName()+","+area.getPnameStr())+"</rs>";
			}
			xml+="</results>";

			PrintWriter pw = response.getWriter();
			pw.print(xml);
			pw.close();

	}

	 public void doPost(HttpServletRequest req, HttpServletResponse resp)
	            throws ServletException, IOException {
	        doGet(req, resp);

	}

}


text:
module Fae
  class ImageUploader < CarrierWave::Uploader::Base
    include CarrierWave::MimeTypes
    include CarrierWave::RMagick

    # saves file size to DB
    process :save_file_size_in_model
    def save_file_size_in_model
      model.file_size = file.size
    end

    def extension_white_list
      %w(jpg jpeg gif png ico)
    end

    # Override the directory where uploaded files will be stored.
    # This is a sensible default for uploaders that are meant to be mounted:
    def store_dir
      "system/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
    end

    version :thumb do
      process :resize_to_fill => [150,100]
    end

  end
end


text:
using namespace DirectX;

using Microsoft::WRL::ComPtr;

namespace
{
    constexpr int Dirty_ConstantBuffer  = 0x01;
    constexpr int Dirty_Parameters      = 0x02;

#if defined(_XBOX_ONE) && defined(_TITLE)
    constexpr int PixelShaderCount = 15;
    constexpr int ShaderPermutationCount = 24;
#else
    constexpr int PixelShaderCount = 9;
    constexpr int ShaderPermutationCount = 12;
#endif

    // Constant buffer layout. Must match the shader!
    __declspec(align(16)) struct ToneMapConstants
    {
        // linearExposure is .x
        // paperWhiteNits is .y
        XMVECTOR parameters;
    };

    static_assert((sizeof(ToneMapConstants) % 16) == 0, "CB size not padded correctly");
}

// Include the precompiled shader code.
namespace
{
#if defined(_XBOX_ONE) && defined(_TITLE)
    #include "Shaders/Compiled/XboxOneToneMap_VSQuad.inc"

    #include "Shaders/Compiled/XboxOneToneMap_PSCopy.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSSaturate.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSReinhard.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSACESFilmic.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PS_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSSaturate_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSReinhard_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSACESFilmic_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_Saturate.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_Reinhard.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_ACESFilmic.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_Saturate_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_Reinhard_SRGB.inc"
    #include "Shaders/Compiled/XboxOneToneMap_PSHDR10_ACESFilmic_SRGB.inc"
#else
    #include "Shaders/Compiled/ToneMap_VSQuad.inc"

    #include "Shaders/Compiled/ToneMap_PSCopy.inc"
    #include "Shaders/Compiled/ToneMap_PSSaturate.inc"
    #include "Shaders/Compiled/ToneMap_PSReinhard.inc"
    #include "Shaders/Compiled/ToneMap_PSACESFilmic.inc"
    #include "Shaders/Compiled/ToneMap_PS_SRGB.inc"
    #include "Shaders/Compiled/ToneMap_PSSaturate_SRGB.inc"
    #include "Shaders/Compiled/ToneMap_PSReinhard_SRGB.inc"
    #include "Shaders/Compiled/ToneMap_PSACESFilmic_SRGB.inc"
    #include "Shaders/Compiled/ToneMap_PSHDR10.inc"
#endif
}

namespace
{
    const D3D12_SHADER_BYTECODE vertexShader =
        { ToneMap_VSQuad,                   sizeof(ToneMap_VSQuad) };

    const D3D12_SHADER_BYTECODE pixelShaders[] =
    {
        { ToneMap_PSCopy,                   sizeof(ToneMap_PSCopy) },
        { ToneMap_PSSaturate,               sizeof(ToneMap_PSSaturate) },
        { ToneMap_PSReinhard,               sizeof(ToneMap_PSReinhard) },
        { ToneMap_PSACESFilmic,             sizeof(ToneMap_PSACESFilmic) },
        { ToneMap_PS_SRGB,                  sizeof(ToneMap_PS_SRGB) },
        { ToneMap_PSSaturate_SRGB,          sizeof(ToneMap_PSSaturate_SRGB) },
        { ToneMap_PSReinhard_SRGB,          sizeof(ToneMap_PSReinhard_SRGB) },
        { ToneMap_PSACESFilmic_SRGB,        sizeof(ToneMap_PSACESFilmic_SRGB) },
        { ToneMap_PSHDR10,                  sizeof(ToneMap_PSHDR10) },

#if defined(_XBOX_ONE) && defined(_TITLE)
        // Shaders that generate both HDR10 and GameDVR SDR signals via Multiple Render Targets.
        { ToneMap_PSHDR10_Saturate,         sizeof(ToneMap_PSHDR10_Saturate) },
        { ToneMap_PSHDR10_Reinhard,         sizeof(ToneMap_PSHDR10_Reinhard) },
        { ToneMap_PSHDR10_ACESFilmic,       sizeof(ToneMap_PSHDR10_ACESFilmic) },
        { ToneMap_PSHDR10_Saturate_SRGB,    sizeof(ToneMap_PSHDR10_Saturate_SRGB) },
        { ToneMap_PSHDR10_Reinhard_SRGB,    sizeof(ToneMap_PSHDR10_Reinhard_SRGB) },
        { ToneMap_PSHDR10_ACESFilmic_SRGB,  sizeof(ToneMap_PSHDR10_ACESFilmic_SRGB) },
#endif
    };

    static_assert(_countof(pixelShaders) == PixelShaderCount, "array/max mismatch");

    const int pixelShaderIndices[] =
    {
        // Linear EOTF
        0,  // Copy
        1,  // Saturate
        2,  // Reinhard
        3,  // ACES Filmic

        // Gamam22 EOTF
        4,  // SRGB
        5,  // Saturate_SRGB
        6,  // Reinhard_SRGB
        7,  // ACES Filmic

        // ST.2084 EOTF
        8,  // HDR10
        8,  // HDR10
        8,  // HDR10
        8,  // HDR10

#if defined(_XBOX_ONE) && defined(_TITLE)
        // MRT Linear EOTF
        9,  // HDR10+Saturate
        9,  // HDR10+Saturate
        10, // HDR10+Reinhard
        11, // HDR10+ACESFilmic

        // MRT Gamma22 EOTF
        12, // HDR10+Saturate_SRGB
        12, // HDR10+Saturate_SRGB
        13, // HDR10+Reinhard_SRGB
        14,  // HDR10+ACESFilmic

        // MRT ST.2084 EOTF
        9,  // HDR10+Saturate
        9,  // HDR10+Saturate
        10, // HDR10+Reinhard
        11, // HDR10+ACESFilmic
#endif
    };

    static_assert(_countof(pixelShaderIndices) == ShaderPermutationCount, "array/max mismatch");

    // Factory for lazily instantiating shared root signatures.
    class DeviceResources
    {
    public:
        DeviceResources(_In_ ID3D12Device* device) noexcept
            : mDevice(device)
        { }

        ID3D12RootSignature* GetRootSignature(const D3D12_ROOT_SIGNATURE_DESC& desc)
        {
            return DemandCreate(mRootSignature, mMutex, [&](ID3D12RootSignature** pResult) noexcept -> HRESULT
            {
                HRESULT hr = CreateRootSignature(mDevice.Get(), &desc, pResult);

                if (SUCCEEDED(hr))
                    SetDebugObjectName(*pResult, L"ToneMapPostProcess");

                return hr;
            });
        }

        ID3D12Device* GetDevice() const noexcept { return mDevice.Get(); }

    protected:
        ComPtr<ID3D12Device>                        mDevice;
        Microsoft::WRL::ComPtr<ID3D12RootSignature> mRootSignature;
        std::mutex                                  mMutex;
    };
}

class ToneMapPostProcess::Impl : public AlignedNew<ToneMapConstants>
{
public:
    Impl(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func, bool mrt = false);

    void Process(_In_ ID3D12GraphicsCommandList* commandList);

    void SetDirtyFlag() noexcept { mDirtyFlags = INT_MAX; }

    enum RootParameterIndex
    {
        TextureSRV,
        ConstantBuffer,
        RootParameterCount
    };

    // Fields.
    ToneMapConstants                        constants;
    D3D12_GPU_DESCRIPTOR_HANDLE             texture;
    float                                   linearExposure;
    float                                   paperWhiteNits;

private:
    int                                     mDirtyFlags;

   // D3D constant buffer holds a copy of the same data as the public 'constants' field.
    GraphicsResource mConstantBuffer;

    // Per instance cache of PSOs, populated with variants for each shader & layout
    Microsoft::WRL::ComPtr<ID3D12PipelineState> mPipelineState;

    // Per instance root signature
    ID3D12RootSignature* mRootSignature;

    // Per-device resources.
    std::shared_ptr<DeviceResources> mDeviceResources;

    static SharedResourcePool<ID3D12Device*, DeviceResources> deviceResourcesPool;
};

// Global pool of per-device ToneMapPostProcess resources.
SharedResourcePool<ID3D12Device*, DeviceResources> ToneMapPostProcess::Impl::deviceResourcesPool;

// Constructor.
ToneMapPostProcess::Impl::Impl(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func, bool mrt)
    : constants{},
    texture{},
    linearExposure(1.f),
    paperWhiteNits(200.f),
    mDirtyFlags(INT_MAX),
    mDeviceResources(deviceResourcesPool.DemandCreate(device))
{
    if (op >= Operator_Max)
        throw std::out_of_range("Tonemap operator not defined");

    if (func > TransferFunction_Max)
        throw std::out_of_range("Transfer function not defined");

    // Create root signature.
    {
        D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags =
            D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS |
            D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS |
            D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS |
            D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS;

        CD3DX12_DESCRIPTOR_RANGE textureSRVs(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0);

        // Same as CommonStates::StaticPointClamp
        CD3DX12_STATIC_SAMPLER_DESC sampler(
            0, // register
            D3D12_FILTER_MIN_MAG_MIP_POINT,
            D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
            D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
            D3D12_TEXTURE_ADDRESS_MODE_CLAMP,
            0.f,
            16,
            D3D12_COMPARISON_FUNC_LESS_EQUAL,
            D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE,
            0.f,
            D3D12_FLOAT32_MAX,
            D3D12_SHADER_VISIBILITY_PIXEL);

        CD3DX12_ROOT_PARAMETER rootParameters[RootParameterIndex::RootParameterCount] = {};

        CD3DX12_DESCRIPTOR_RANGE texture1Range(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0);
        rootParameters[RootParameterIndex::TextureSRV].InitAsDescriptorTable(1, &textureSRVs, D3D12_SHADER_VISIBILITY_PIXEL);

        // Root parameter descriptor
        CD3DX12_ROOT_SIGNATURE_DESC rsigDesc = {};

        // Constant buffer
        rootParameters[RootParameterIndex::ConstantBuffer].InitAsConstantBufferView(0, 0, D3D12_SHADER_VISIBILITY_PIXEL);

        rsigDesc.Init(_countof(rootParameters), rootParameters, 1, &sampler, rootSignatureFlags);

        mRootSignature = mDeviceResources->GetRootSignature(rsigDesc);
    }

    assert(mRootSignature != nullptr);

    // Determine shader permutation.
#if defined(_XBOX_ONE) && defined(_TITLE)
    int permutation = (mrt) ? 12 : 0;
    permutation += (static_cast<int>(func) * static_cast<int>(Operator_Max)) + static_cast<int>(op);
#else
    UNREFERENCED_PARAMETER(mrt);
    int permutation = (static_cast<int>(func) * static_cast<int>(Operator_Max)) + static_cast<int>(op);
#endif

    assert(permutation >= 0 && permutation < ShaderPermutationCount);
    _Analysis_assume_(permutation >= 0 && permutation < ShaderPermutationCount);

    int shaderIndex = pixelShaderIndices[permutation];
    assert(shaderIndex >= 0 && shaderIndex < PixelShaderCount);
    _Analysis_assume_(shaderIndex >= 0 && shaderIndex < PixelShaderCount);

    // Create pipeline state.
    EffectPipelineStateDescription psd(nullptr,
        CommonStates::Opaque,
        CommonStates::DepthNone,
        CommonStates::CullNone,
        rtState,
        D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE);

    psd.CreatePipelineState(
        device,
        mRootSignature,
        vertexShader,
        pixelShaders[shaderIndex],
        mPipelineState.GetAddressOf());

    SetDebugObjectName(mPipelineState.Get(), L"ToneMapPostProcess");
}

// Sets our state onto the D3D device.
void ToneMapPostProcess::Impl::Process(_In_ ID3D12GraphicsCommandList* commandList)
{
    // Set the root signature.
    commandList->SetGraphicsRootSignature(mRootSignature);

    // Set the texture.
    if (!texture.ptr)
    {
        DebugTrace("ERROR: Missing texture for ToneMapPostProcess (texture %llu)\n", texture.ptr);
        throw std::exception("ToneMapPostProcess");
    }
    commandList->SetGraphicsRootDescriptorTable(RootParameterIndex::TextureSRV, texture);

    // Set constants.
    if (mDirtyFlags & Dirty_Parameters)
    {
        mDirtyFlags &= ~Dirty_Parameters;
        mDirtyFlags |= Dirty_ConstantBuffer;

        constants.parameters = XMVectorSet(linearExposure, paperWhiteNits, 0.f, 0.f);
    }

    if (mDirtyFlags & Dirty_ConstantBuffer)
    {
        mDirtyFlags &= ~Dirty_ConstantBuffer;
        mConstantBuffer = GraphicsMemory::Get(mDeviceResources->GetDevice()).AllocateConstant(constants);
    }

    commandList->SetGraphicsRootConstantBufferView(RootParameterIndex::ConstantBuffer, mConstantBuffer.GpuAddress());

    // Set the pipeline state.
    commandList->SetPipelineState(mPipelineState.Get());

    // Draw quad.
    commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    commandList->DrawInstanced(3, 1, 0, 0);
}

// Public constructor.
#if defined(_XBOX_ONE) && defined(_TITLE)
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func, bool mrt)
  : pImpl(std::make_unique<Impl>(device, rtState, op, func, mrt))
#else
ToneMapPostProcess::ToneMapPostProcess(_In_ ID3D12Device* device, const RenderTargetState& rtState, Operator op, TransferFunction func)
    : pImpl(std::make_unique<Impl>(device, rtState, op, func))
#endif
{
}

// Move constructor.
ToneMapPostProcess::ToneMapPostProcess(ToneMapPostProcess&& moveFrom) noexcept
  : pImpl(std::move(moveFrom.pImpl))
{
}

// Move assignment.
ToneMapPostProcess& ToneMapPostProcess::operator= (ToneMapPostProcess&& moveFrom) noexcept
{
    pImpl = std::move(moveFrom.pImpl);
    return *this;
}

// Public destructor.
ToneMapPostProcess::~ToneMapPostProcess()
{
}

// IPostProcess methods.
void ToneMapPostProcess::Process(_In_ ID3D12GraphicsCommandList* commandList)
{
    pImpl->Process(commandList);
}

// Properties
void ToneMapPostProcess::SetHDRSourceTexture(D3D12_GPU_DESCRIPTOR_HANDLE srvDescriptor)
{
    pImpl->texture = srvDescriptor;
}

void ToneMapPostProcess::SetExposure(float exposureValue)
{
    pImpl->linearExposure = powf(2.f, exposureValue);
    pImpl->SetDirtyFlag();
}

void ToneMapPostProcess::SetST2084Parameter(float paperWhiteNits)
{
    pImpl->paperWhiteNits = paperWhiteNits;
    pImpl->SetDirtyFlag();
}


text:
class BMFF::Box::SampleDescription < BMFF::Box::Full
  attr_accessor :entry_count
  register_box "stsd"
  include(BMFF::Box::Container)

  def parse_data
    super
    @entry_count = io.get_uint32
    if handler = parent.parent.parent.find(BMFF::Box::Handler)
      @entry_count.times do
        case handler.handler_type
        when "soun"
          add_child BMFF::Box.get_box(io, self, BMFF::Box::AudioSampleEntry)
        when "vide"
          add_child BMFF::Box.get_box(io, self, BMFF::Box::VisualSampleEntry)
        when "hint"
          add_child BMFF::Box.get_box(io, self, BMFF::Box::HintSampleEntry)
        when "meta"
          add_child BMFF::Box.get_box(io, self)
        end
      end
    end
  end
end


text:
package jme3test.input;

import com.jme3.app.SimpleApplication;
import com.jme3.collision.CollisionResult;
import com.jme3.collision.CollisionResults;
import com.jme3.font.BitmapText;
import com.jme3.input.Joystick;
import com.jme3.input.JoystickAxis;
import com.jme3.input.JoystickButton;
import com.jme3.input.MouseInput;
import com.jme3.input.RawInputListener;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.input.event.JoyAxisEvent;
import com.jme3.input.event.JoyButtonEvent;
import com.jme3.input.event.KeyInputEvent;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.input.event.TouchEvent;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Ray;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Quad;
import com.jme3.system.AppSettings;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class TestJoystick extends SimpleApplication {

    private Joystick viewedJoystick;
    private GamepadView gamepad;
    private Node joystickInfo;
    private float yInfo = 0;
    private JoystickButton lastButton;

    public static void main(String[] args){
        TestJoystick app = new TestJoystick();
        AppSettings settings = new AppSettings(true);
        settings.setUseJoysticks(true);
        app.setSettings(settings);
        app.start();
    }

    @Override
    public void simpleInitApp() {
        getFlyByCamera().setEnabled(false);

        Joystick[] joysticks = inputManager.getJoysticks();
        if (joysticks == null)
            throw new IllegalStateException("Cannot find any joysticks!");

        try {
            PrintWriter out = new PrintWriter( new FileWriter( "joysticks-" + System.currentTimeMillis() + ".txt" ) );
            dumpJoysticks( joysticks, out );
            out.close();
        } catch( IOException e ) {
            throw new RuntimeException( "Error writing joystick dump", e );
        }

        int gamepadSize = cam.getHeight() / 2;
        float scale = gamepadSize / 512.0f;
        gamepad = new GamepadView();
        gamepad.setLocalTranslation( cam.getWidth() - gamepadSize - (scale * 20), 0, 0 );
        gamepad.setLocalScale( scale, scale, scale );
        guiNode.attachChild(gamepad);

        joystickInfo = new Node( "joystickInfo" );
        joystickInfo.setLocalTranslation( 0, cam.getHeight(), 0 );
        guiNode.attachChild( joystickInfo );

        // Add a raw listener because it's easier to get all joystick events
        // this way.
        inputManager.addRawInputListener( new JoystickEventListener() );

        // add action listener for mouse click
        // to all easier custom mapping
        inputManager.addMapping("mouseClick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(new ActionListener() {
            @Override
            public void onAction(String name, boolean isPressed, float tpf) {
                if(isPressed){
                    pickGamePad(getInputManager().getCursorPosition());
                }
            }
        }, "mouseClick");
    }

    protected void dumpJoysticks( Joystick[] joysticks, PrintWriter out ) {
        for( Joystick j : joysticks ) {
            out.println( "Joystick[" + j.getJoyId() + "]:" + j.getName() );
            out.println( "  buttons:" + j.getButtonCount() );
            for( JoystickButton b : j.getButtons() ) {
                out.println( "   " + b );
            }

            out.println( "  axes:" + j.getAxisCount() );
            for( JoystickAxis axis : j.getAxes() ) {
                out.println( "   " + axis );
            }
        }
    }

    protected void addInfo( String info, int column ) {

        BitmapText t = new BitmapText(guiFont);
        t.setText( info );
        t.setLocalTranslation( column * 200, yInfo, 0 );
        joystickInfo.attachChild(t);
        yInfo -= t.getHeight();
    }

    protected void setViewedJoystick( Joystick stick ) {
        if( this.viewedJoystick == stick )
            return;

        if( this.viewedJoystick != null ) {
            joystickInfo.detachAllChildren();
        }

        this.viewedJoystick = stick;

        if( this.viewedJoystick != null ) {
            // Draw the hud
            yInfo = 0;

            addInfo(  "Joystick:\"" + stick.getName() + "\"  id:" + stick.getJoyId(), 0 );

            yInfo -= 5;

            float ySave = yInfo;

            // Column one for the buttons
            addInfo( "Buttons:", 0 );
            for( JoystickButton b : stick.getButtons() ) {
                addInfo( " '" + b.getName() + "' id:'" + b.getLogicalId() + "'", 0 );
            }
            yInfo = ySave;

            // Column two for the axes
            addInfo( "Axes:", 1 );
            for( JoystickAxis a : stick.getAxes() ) {
                addInfo( " '" + a.getName() + "' id:'" + a.getLogicalId() + "' analog:" + a.isAnalog(), 1 );
            }

        }
    }

    /**
     *  Easier to watch for all button and axis events with a raw input listener.
     */
    protected class JoystickEventListener implements RawInputListener {

        final private Map<JoystickAxis, Float> lastValues = new HashMap<>();

        @Override
        public void onJoyAxisEvent(JoyAxisEvent evt) {
            Float last = lastValues.remove(evt.getAxis());
            float value = evt.getValue();

            // Check the axis dead zone.  InputManager normally does this
            // by default but not for raw events like we get here.
            float effectiveDeadZone = Math.max(inputManager.getAxisDeadZone(), evt.getAxis().getDeadZone());
            if( Math.abs(value) < effectiveDeadZone ) {
                if( last == null ) {
                    // Just skip the event
                    return;
                }
                // Else set the value to 0
                lastValues.remove(evt.getAxis());
                value = 0;
            }
            setViewedJoystick( evt.getAxis().getJoystick() );
            gamepad.setAxisValue( evt.getAxis(), value );
            if( value != 0 ) {
                lastValues.put(evt.getAxis(), value);
            }
        }

        @Override
        public void onJoyButtonEvent(JoyButtonEvent evt) {
            setViewedJoystick( evt.getButton().getJoystick() );
            gamepad.setButtonValue( evt.getButton(), evt.isPressed() );
        }

        @Override
        public void beginInput() {}
        @Override
        public void endInput() {}
        @Override
        public void onMouseMotionEvent(MouseMotionEvent evt) {}
        @Override
        public void onMouseButtonEvent(MouseButtonEvent evt) {}
        @Override
        public void onKeyEvent(KeyInputEvent evt) {}
        @Override
        public void onTouchEvent(TouchEvent evt) {}
    }

    protected class GamepadView extends Node {

        private float xAxis = 0;
        private float yAxis = 0;
        private float zAxis = 0;
        private float zRotation = 0;

        private float lastPovX = 0;
        private float lastPovY = 0;

        final private Geometry leftStick;
        final private Geometry rightStick;

        final private Map<String, ButtonView> buttons = new HashMap<>();

        public GamepadView() {
            super( "gamepad" );

            // Sizes naturally for the texture size.  All positions will
            // be in that space because it's easier.
            int size = 512;

            Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            m.setTexture( "ColorMap", assetManager.loadTexture( "Interface/Joystick/gamepad-buttons.png" ) );
            m.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );
            Geometry buttonPanel = new Geometry( "buttons", new Quad(size, size) );
            buttonPanel.setLocalTranslation( 0, 0, -1 );
            buttonPanel.setMaterial(m);
            attachChild(buttonPanel);

            m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            m.setTexture( "ColorMap", assetManager.loadTexture( "Interface/Joystick/gamepad-frame.png" ) );
            m.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );
            Geometry frame = new Geometry( "frame", new Quad(size, size) );
            frame.setMaterial(m);
            attachChild(frame);

            m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            m.setTexture( "ColorMap", assetManager.loadTexture( "Interface/Joystick/gamepad-stick.png" ) );
            m.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );
            leftStick = new Geometry( "leftStick", new Quad(64, 64) );
            leftStick.setMaterial(m);
            attachChild(leftStick);
            rightStick = new Geometry( "rightStick", new Quad(64, 64) );
            rightStick.setMaterial(m);
            attachChild(rightStick);

            // A "standard" mapping... fits a majority of my game pads
            addButton( JoystickButton.BUTTON_0, 371, 512 - 176, 42, 42 );
            addButton( JoystickButton.BUTTON_1, 407, 512 - 212, 42, 42 );
            addButton( JoystickButton.BUTTON_2, 371, 512 - 248, 42, 42 );
            addButton( JoystickButton.BUTTON_3, 334, 512 - 212, 42, 42 );

            // Front buttons  Some of these have the top ones and the bottoms ones flipped.
            addButton( JoystickButton.BUTTON_4, 67, 512 - 111, 95, 21 );
            addButton( JoystickButton.BUTTON_5, 348, 512 - 111, 95, 21 );
            addButton( JoystickButton.BUTTON_6, 67, 512 - 89, 95, 21 );
            addButton( JoystickButton.BUTTON_7, 348, 512 - 89, 95, 21 );

            // Select and start buttons
            addButton( JoystickButton.BUTTON_8, 206, 512 - 198, 48, 30 );
            addButton( JoystickButton.BUTTON_9, 262, 512 - 198, 48, 30 );

            // Joystick push buttons
            addButton( JoystickButton.BUTTON_10, 147, 512 - 300, 75, 70 );
            addButton( JoystickButton.BUTTON_11, 285, 512 - 300, 75, 70 );

            // Fake button highlights for the POV axes
            //
            //    +Y
            //  -X  +X
            //    -Y
            //
            addButton( "POV +Y", 96, 512 - 174, 40, 38 );
            addButton( "POV +X", 128, 512 - 208, 40, 38 );
            addButton( "POV -Y", 96, 512 - 239, 40, 38 );
            addButton( "POV -X", 65, 512 - 208, 40, 38 );

            resetPositions();
        }

        private void addButton( String name, float x, float y, float width, float height ) {
            ButtonView b = new ButtonView(name, x, y, width, height);
            attachChild(b);
            buttons.put(name, b);
        }

        public void setAxisValue( JoystickAxis axis, float value ) {

            System.out.println( "Axis:" + axis.getName() + "(id:" + axis.getLogicalId() + ")=" + value );
            if( axis == axis.getJoystick().getXAxis() ) {
                setXAxis(value);
            } else if( axis == axis.getJoystick().getYAxis() ) {
                setYAxis(-value);
            } else if( axis == axis.getJoystick().getAxis(JoystickAxis.Z_AXIS) ) {
                // Note: in the above condition, we could check the axis name, but
                //       I have at least one joystick that reports 2 "Z Axis" axes.
                //       In this particular case, the first one is the right one so
                //       a name based lookup will find the proper one.  It's a problem
                //       because the erroneous axis sends a constant stream of values.
                setZAxis(value);
            } else if( axis == axis.getJoystick().getAxis(JoystickAxis.Z_ROTATION) ) {
                setZRotation(-value);
            } else if( axis == axis.getJoystick().getAxis(JoystickAxis.LEFT_TRIGGER) ) {
                if( axis.getJoystick().getButton(JoystickButton.BUTTON_6) == null ) {
                    // left/right triggers sometimes only show up as axes
                    boolean pressed = value != 0;
                    if( pressed != buttons.get(JoystickButton.BUTTON_6).isDown() ) {
                        setButtonValue(JoystickButton.BUTTON_6, pressed);
                    }
                }
            } else if( axis == axis.getJoystick().getAxis(JoystickAxis.RIGHT_TRIGGER) ) {
                if( axis.getJoystick().getButton(JoystickButton.BUTTON_7) == null ) {
                    // left/right triggers sometimes only show up as axes
                    boolean pressed = value != 0;
                    if( pressed != buttons.get(JoystickButton.BUTTON_7).isDown() ) {
                        setButtonValue(JoystickButton.BUTTON_7, pressed);
                    }
                }
            } else if( axis == axis.getJoystick().getPovXAxis() ) {
                if( lastPovX < 0 ) {
                    setButtonValue( "POV -X", false );
                } else if( lastPovX > 0 ) {
                    setButtonValue( "POV +X", false );
                }
                if( value < 0 ) {
                    setButtonValue( "POV -X", true );
                } else if( value > 0 ) {
                    setButtonValue( "POV +X", true );
                }
                lastPovX = value;
            } else if( axis == axis.getJoystick().getPovYAxis() ) {
                if( lastPovY < 0 ) {
                    setButtonValue( "POV -Y", false );
                } else if( lastPovY > 0 ) {
                    setButtonValue( "POV +Y", false );
                }
                if( value < 0 ) {
                    setButtonValue( "POV -Y", true );
                } else if( value > 0 ) {
                    setButtonValue( "POV +Y", true );
                }
                lastPovY = value;
            }
        }

        public void setButtonValue( JoystickButton button, boolean isPressed ) {
            System.out.println( "Button:" + button.getName() + "=" + (isPressed ? "Down" : "Up") );
            setButtonValue( button.getLogicalId(), isPressed );
            lastButton = button;
        }

        protected void setButtonValue( String name, boolean isPressed ) {
            ButtonView view = buttons.get(name);
            if( view != null ) {
                if( isPressed ) {
                    view.down();
                } else {
                    view.up();
                }
            }
        }

        public void setXAxis( float f ) {
            xAxis = f;
            resetPositions();
        }

        public void setYAxis( float f ) {
            yAxis = f;
            resetPositions();
        }

        public void setZAxis( float f ) {
            zAxis = f;
            resetPositions();
        }

        public void setZRotation( float f ) {
            zRotation = f;
            resetPositions();
        }

        private void resetPositions() {

            float xBase = 155;
            float yBase = 212;

            Vector2f dir = new Vector2f(xAxis, yAxis);
            float length = Math.min(1, dir.length());
            dir.normalizeLocal();

            float angle = dir.getAngle();
            float x = FastMath.cos(angle) * length * 10;
            float y = FastMath.sin(angle) * length * 10;
            leftStick.setLocalTranslation( xBase + x, yBase + y, 0 );

            xBase = 291;
            dir = new Vector2f(zAxis, zRotation);
            length = Math.min(1, dir.length());
            dir.normalizeLocal();

            angle = dir.getAngle();
            x = FastMath.cos(angle) * length * 10;
            y = FastMath.sin(angle) * length * 10;
            rightStick.setLocalTranslation( xBase + x, yBase + y, 0 );
        }
    }

    protected class ButtonView extends Node {

        private int state = 0;
        final private Material material;
        final private ColorRGBA hilite = new ColorRGBA( 0.0f, 0.75f, 0.75f, 0.5f );

        public ButtonView( String name, float x, float y, float width, float height ) {
            super( "Button:" + name );
            setLocalTranslation( x, y, -0.5f );

            material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            material.setColor( "Color", hilite );
            material.getAdditionalRenderState().setBlendMode( BlendMode.Alpha );

            Geometry g = new Geometry( "highlight", new Quad(width, height) );
            g.setMaterial(material);
            attachChild(g);

            resetState();
        }

        private void resetState() {
            if( state <= 0 ) {
                setCullHint( CullHint.Always );
            } else {
                setCullHint( CullHint.Dynamic );
            }

            System.out.println( getName() + " state:" + state );
        }

        public boolean isDown() {
            return state > 0;
        }

        public void down() {
            state++;
            resetState();
        }

        public void up() {
            state--;
            resetState();
        }
    }

    private void pickGamePad(Vector2f mouseLoc){
        if (lastButton != null) {
            CollisionResults results = pick(cam, mouseLoc, gamepad);
            for (CollisionResult cr : results) {
                Node n = cr.getGeometry().getParent();
                if (n != null && (n instanceof ButtonView)) {
                    String b = n.getName().substring("Button:".length());
                    String name = lastButton.getJoystick().getName().replaceAll(" ", "\\\\ ");
                    String id = lastButton.getLogicalId().replaceAll(" ", "\\\\ ");
                    System.out.println(name + "." + id + "=" + b);
                    return;
                }
            }
        }
    }

    private static CollisionResults pick(Camera cam, Vector2f mouseLoc, Node node) {
        CollisionResults results = new CollisionResults();
        Ray ray = new Ray();
        Vector3f pos = new Vector3f(mouseLoc.x, mouseLoc.y, -1);
        Vector3f dir = new Vector3f(mouseLoc.x, mouseLoc.y, 1);
        dir.subtractLocal(pos).normalizeLocal();
        ray.setOrigin(pos);
        ray.setDirection(dir);
        node.collideWith(ray, results);
        return results;
    }
}