text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Smart.Web.Mvc.UI.JqGrid.DataReaders;
using Smart.Core.Extensions;

namespace Smart.Web.Mvc.UI.JqGrid
{
    /// <summary>
    ///
    /// </summary>
    public class Grid : IHtmlString
    {
        #region 私有字段
        private readonly List<Column> _columns = new List<Column>();
        private readonly string _id;
        private bool _asyncLoad;
        private string _altClass;
        private bool _altRows = false;
        private bool _autoEncode = false;
        private bool _autoWidth = false;
        private string _caption;
        private int _cellLayout = 5;

        private bool _cellEdit = false;
        private SubmitType _cellsubmit = SubmitType.Remote;
        private string _cellurl;

        //private object _cmTemplate;
        //private object[] _data;
        //private string _datastr;
        private bool _stringResult = true;
        private DataType _dataType = DataType.Json;
        private bool _deepempty = false;
        private bool _deselectAfterSort = true;
        //private string _direction;
        private Direction? _sortIconDirection;
        private string _editurl;
        private string _emptyRecords;   //see lang file
        private bool _footerRow = false;
        private bool _forceFit = false;
        private GridState _gridstate = GridState.Visible;
        private bool _gridView = false;

        private bool _grouping = false;
        private GroupingView _groupingView;

        private bool _headerTitles = false;
        private int _height = 150;
        private bool _hiddenGrid = false;
        private bool _hideGrid = true;
        private bool _hoverRows = true;
        //private string _idPrefix;
        private bool _ignoreCase = false;
        //private object _inlineData;
        private JsonReader _jsonReader;
        //private int _lastpage = 0;
        private bool _loadonce = false;
        private string _loadtext;
        private LoadUi _loadui = LoadUi.Enable;
        private RequestType? _mtype = RequestType.Get;

        private MultiKey _multiKey = MultiKey.None;
        private bool _multiboxOnly = false;
        private bool _multiSelect = false;
        private int _multiSelectWidth = 20;
        private bool _multiSort = false;

        private int _page = 0;
        private bool _pager = false;
        private PagerPos _pagerPos = PagerPos.Center;
        private bool _pgButtons = true;
        private bool _pgInput = true;
        private string _pgText;
        //private object _postData;
        private RecordPos _recordPos = RecordPos.Right;
        private string _recordText;
        private bool _topPager = false;
        private bool _viewRecords = false;
        //private bool _viewsortcols = false;//[false,'vertical',true]

        private string _resizeClass;

        private int[] _rowList;
        private bool _rowNumbers = false;
        private int _rowNum = 20;
        //private int? _rowTotal;
        private int _rowNumWidth = 25;

        private bool _scroll = false;
        private int _scrollOffset = 18;
        private int _scrollTimeout = 200;
        private bool _scrollRows = false;
        private int? _scrollInt;

        private bool _shrinkToFit = true;
        private int _shrinkToFitInt;

        private bool _sortable = false;
        private string _sortName;
        private SortOrder _sortOrder = SortOrder.Asc;

        //private bool _subGrid = false;
        //private object _subGridOptions;
        //private object[] _subGridModel;
        //private string _subGridType;
        //private string _subGridUrl;
        //private int _subGridWidth = 20;

        private bool _toolbar = false;
        private ToolbarPosition _toolbarPosition = ToolbarPosition.Top;

        private bool _treeGrid = false;
        private TreeGridModel _treeGridModel = TreeGridModel.Nested;
        //private TreeIcons _treeIcons;
        //private object _treeReader;
        private int? _treeRootLevel;
        //private bool _ExpandColClick = true;
        //private string ExpandColumn;

        private string _url;

        //private object _userData;
        private bool _userDataOnFooter;

        private int? _width;

        private bool? _searchClearButton;
        private bool? _searchOnEnter;
        private bool? _searchToolbar;
        private bool? _showAllSortIcons;
        private bool? _sortOnHeaderClick;
        private bool? _searchToggleButton;
        private string _rowAttr;

        private string _onAfterInsertRow;
        private string _onBeforeRequest;
        private string _onBeforeSelectRow;
        private string _onCellSelect;
        private string _onDblClickRow;
        private string _onGridComplete;
        private string _onHeaderClick;
        private string _onLoadBeforeSend;
        private string _onLoadComplete;
        private string _onLoadError;
        private string _onPaging;
        private string _onResizeStart;
        private string _onResizeStop;
        private string _onRightClickRow;
        private string _onSelectAll;
        private string _onSelectRow;
        private string _onSerializeGridData;
        private string _onSortCol;

        #endregion

        /// <summary>
        ///     构造函数
        /// </summary>
        /// <param name = "id">Id of grid</param>
        /// <param name = "caption"></param>
        /// <param name = "url"></param>
        /// <param name = "asyncLoad"></param>
        public Grid(string id, string caption = null, string url = null, bool asyncLoad = false)
        {
            if (id.IsEmpty())
            {
                throw new ArgumentException("Id参数不能设置为空!必需为有效的HTML节点ID");
            }
            _id = id;
            _caption = caption;
            _url = url;
            _asyncLoad = asyncLoad;

            _autoWidth = true;
            _pager = true;
            _mtype = RequestType.Post;
        }

        #region 属性

        /// <summary>
        ///  新增列
        /// </summary>
        /// <param name = "column">Colomn object</param>
        public Grid AddColumn(Column column)
        {
            _columns.Add(column);
            return this;
        }

        /// <summary>
        ///  新增多个列
        /// </summary>
        /// <param name = "columns">IEnumerable of Colomn objects to add to the grid</param>
        public Grid AddColumns(IEnumerable<Column> columns)
        {
            _columns.AddRange(columns);
            return this;
        }

        /// <summary>
        ///  设置交替行样式,
        ///  此选项仅当altrows选项设置为True是有效的,(默认值:ui-priority-secondary)
        /// </summary>
        /// <param name = "altClass">Classname for alternate rows</param>
        public Grid SetAltClass(string altClass)
        {
            _altClass = altClass;
            return this;
        }

        /// <summary>
        /// 启用或禁用交替行样式
        /// </summary>
        /// <param name = "altRows"></param>
        public Grid SetAltRows(bool altRows = true)
        {
            _altRows = altRows;
            return this;
        }

        /// <summary>
        /// 启用或禁用对url进行编码,默认false
        /// </summary>
        /// <param name = "autoEncode">当为 ture 时对url进行编码</param>
        public Grid SetAutoEncode(bool autoEncode = true)
        {
            _autoEncode = autoEncode;
            return this;
        }

        /// <summary>
        ///     启用或禁用自动计算宽度 (默认值:false)
        /// </summary>
        /// <param name = "autoWidth">
        ///     为ture时,则当表格在首次被创建时会根据父元素比例重新调整表格宽度。
        ///     如果父元素宽度改变,为了使表格宽度能够自动调整则需要实现函数:setGridWidth
        /// </param>
        public Grid SetAutoWidth(bool autoWidth = true)
        {
            _autoWidth = autoWidth;
            return this;
        }

        /// <summary>
        ///     设置表格标题内容
        /// </summary>
        /// <param name = "caption">标题内容</param>
        public Grid SetCaption(string caption)
        {
            _caption = caption;
            return this;
        }

        /// <summary>
        /// 定义了单元格padding + border 宽度。通常不必修改此值。初始值为5,paddingLef?2+paddingRight?2+borderLeft?1=5
        /// </summary>
        /// <param name="cellLayout"></param>
        /// <returns></returns>
        public Grid SetCellLayout(int cellLayout)
        {
            _cellLayout = cellLayout;
            return this;
        }

        /// <summary>
        /// 启用或者禁用单元格编辑功能
        /// </summary>
        /// <param name="cellSubmit"></param>
        /// <param name="cellUrl"></param>
        /// <returns></returns>
        public Grid SetCellEdit(SubmitType cellSubmit = SubmitType.Remote, string cellUrl = null)
        {
            _cellEdit = true;
            _cellsubmit = cellSubmit;
            _cellurl = cellUrl;
            return this;
        }

        /// <summary>
        ///  设置从服务器端返回的数据类型,默认json。
        /// </summary>
        /// <param name = "dataType"></param>
        public Grid SetDataType(DataType dataType)
        {
            _dataType = dataType;
            return this;
        }

        /// <summary>
        ///     设置为true。此配置使用 jQuery empty作用于行和行的子元素。
        ///     会有速度开销,但是可以防止内存泄露。
        ///     可排序的行或者列激活时也需要设置为true
        /// </summary>
        /// <param name="deepempty"></param>
        /// <returns></returns>
        public Grid SetDeepEmpty(bool deepempty = true)
        {
            _deepempty = deepempty;
            return this;
        }

        /// <summary>
        ///  当排序时不选择当前行,只有当datatype为local时起作用。
        /// </summary>
        /// <param name="deselectAfterSort"></param>
        /// <returns></returns>
        public Grid SetDeselectAfterSort(bool deselectAfterSort = true)
        {
            _deselectAfterSort = deselectAfterSort;
            return this;
        }

        /// <summary>
        ///     定义行编辑或者表单编辑时完成编辑后保存数据的动态页地址。
        ///     可以设置为客户端数组 clientArray 然后手动提交数据到服务器。
        /// </summary>
        /// <param name="editurl"></param>
        /// <returns></returns>
        public Grid SetEditUrl(string editurl)
        {
            _editurl = editurl;
            return this;
        }

        /// <summary>
        /// 设置当返回的数据行数为0时显示的信息。只有当属性 viewrecords 设置为ture时起作用
        /// </summary>
        /// <param name = "emptyRecords"></param>
        public Grid SetEmptyRecords(string emptyRecords)
        {
            _emptyRecords = emptyRecords;
            return this;
        }

        /// <summary>
        ///    启用或禁用显示表格页脚行
        /// </summary>
        /// <param name = "footerRow"></param>
        public Grid SetFooterRow(bool footerRow = true)
        {
            _footerRow = footerRow;
            return this;
        }

        /// <summary>
        /// 启用或禁调整列宽度不会改变表格的宽度。当shrinkToFit 为false时,此属性会被忽略
        /// </summary>
        /// <param name = "forceFit"></param>
        public Grid SetForceFit(bool forceFit = true)
        {
            _forceFit = forceFit;
            return this;
        }

        /// <summary>
        /// 定义当前表格的状态:'visible'(默认) or 'hidden'
        /// </summary>
        /// <param name="gridState"></param>
        /// <returns></returns>
        public Grid SetGridState(GridState gridState)
        {
            _gridstate = gridState;
            return this;
        }

        /// <summary>
        ///     构造一行数据后添加到grid中,
        ///     如果设为true则是将整个表格的数据都构造完成后再添加到grid中,
        ///     但treeGrid, subGrid, or afterInsertRow 不能用
        /// </summary>
        /// <param name = "gridView"></param>
        public Grid SetGridView(bool gridView = true)
        {
            _gridView = gridView;
            return this;
        }

        /// <summary>
        /// 启用分组功能
        /// </summary>
        /// <param name="groupingView"></param>
        /// <returns></returns>
        public Grid SetGrouping(GroupingView groupingView = null)
        {
            _grouping = true;
            _groupingView = groupingView;

            // 当启用分组时,下面的选项的值设置成这样
            _scroll = false;
            _rowNumbers = false;
            _treeGrid = false;
            _gridView = true; //(afterInsertRow不会触发)
            return this;
        }

        /// <summary>
        ///   启用或禁用title
        /// </summary>
        /// <param name = "headerTitles">设置为true将会添加到表头的title属性</param>
        public Grid SetHeaderTitles(bool headerTitles = true)
        {
            _headerTitles = headerTitles;
            return this;
        }

        /// <summary>
        /// 设置表格高度,可以是数字,像素值或者百分比
        /// </summary>
        /// <param name = "height"></param>
        public Grid SetHeight(int height)
        {
            _height = height;
            return this;
        }

        /// <summary>
        ///     当为ture时,表格不会被显示,只显示表格的标题。
        ///     只有当点击显示表格的那个按钮时才会去初始化表格数据。默认false
        /// </summary>
        /// <param name = "hiddenGrid"></param>
        public Grid SetHiddenGrid(bool hiddenGrid = true)
        {
            _hiddenGrid = hiddenGrid;
            return this;
        }

        /// <summary>
        ///  启用或禁用显示/隐藏"网格"按钮,该按钮出现在标题层右侧。
        ///  仅当标题属性不是空字符串时才生效。(默认值:true)
        /// </summary>
        /// <param name = "hideGrid">Boolean indicating if show/hide button is enabled</param>
        public Grid SetHideGrid(bool hideGrid = true)
        {
            _hideGrid = hideGrid;
            return this;
        }

        /// <summary>
        /// 启用或禁用行的鼠标悬停效果,默认值:true
        /// </summary>
        /// <param name = "hoverRows"></param>
        public Grid SetHoverRows(bool hoverRows = true)
        {
            _hoverRows = hoverRows;
            return this;
        }

        /// <summary>
        /// 设置查询和排序是否区分大小写。
        /// </summary>
        /// <param name="ignoreCase">设置为true区分大小写</param>
        /// <returns></returns>
        public Grid SetIgnoreCase(bool ignoreCase = true)
        {
            _ignoreCase = ignoreCase;
            return this;
        }

        /// <summary>
        ///     描述json 数据格式的配置
        /// </summary>
        /// <param name="jsonReader"></param>
        /// <returns></returns>
        public Grid SetJsonReader(JsonReader jsonReader)
        {
            _jsonReader = jsonReader;
            return this;
        }

        /// <summary>
        /// 如果为ture则数据只从服务器端抓取一次,之后所有操作都是在客户端执行,翻页功能会被禁用,默认为false
        /// </summary>
        /// <param name = "loadOnce"></param>
        public Grid SetLoadOnce(bool loadOnce = true)
        {
            _loadonce = loadOnce;
            return this;
        }

        /// <summary>
        /// 设置当请求或者排序时所显示的文字内容
        /// </summary>
        /// <param name = "loadText">Loadtext</param>
        public Grid SetLoadText(string loadText)
        {
            _loadtext = loadText;
            return this;
        }

        /// <summary>
        ///     当执行ajax请求时要干什么。
        ///     disable禁用ajax执行提示;
        ///     enable默认,当执行ajax请求时的提示;
        ///     block启用Loading提示,但是阻止其他操作
        /// </summary>
        /// <param name = "loadUi">Load ui mode</param>
        public Grid SetLoadUi(LoadUi loadUi)
        {
            _loadui = loadUi;
            return this;
        }

        /// <summary>
        ///  设置ajax提交方式。POST或者GET,默认GET
        /// </summary>
        /// <param name = "requestType"></param>
        public Grid SetMType(RequestType requestType)
        {
            _mtype = requestType;
            return this;
        }

        /// <summary>
        ///     启用或禁用多选,默认值:false
        /// </summary>
        /// <param name = "multiSelect">为 true 时显示多选列</param>
        /// <param name="multiBoxOnly">为 ture 时只有选择checkbox才会起作用</param>
        /// <param name="multiKey">定义使用那个key来做多选</param>
        /// <param name="multiSelectWidth">multiselect列宽度,默认值:20</param>
        /// <returns></returns>
        public Grid SetMultiSelect(bool multiSelect = true, bool multiBoxOnly = false, MultiKey multiKey = MultiKey.None, int multiSelectWidth = 20)
        {
            _multiSelect = multiSelect;
            _multiboxOnly = multiBoxOnly;
            _multiKey = multiKey;
            _multiSelectWidth = multiSelectWidth;
            return this;
        }

        /// <summary>
        ///     是否允许多重排序,仅当datatype为local时有效。
        ///     sidx包含发送给服务器端排序的内容。
        ///     排序的字段 用逗号分隔,如"field1 asc, field2 desc …, fieldN"。
        ///     注意最后的字段不包含asc 或者desc。
        ///     设置为ture时通过sord参数获取
        /// </summary>
        /// <param name="multiSort"></param>
        /// <returns></returns>
        public Grid SetMultiSort(bool multiSort = true)
        {
            _multiSort = multiSort;
            return this;
        }

        /// <summary>
        /// 设置翻页用的导航栏
        /// </summary>
        /// <param name="page">设置初始页码,默认值:1</param>
        /// <param name="rowNum">设置在grid上显示记录条数,这个参数是要被传递到后台,默认20</param>
        /// <param name="rowList">设置分页行数下拉选择框数据源,用来改变显示记录数,当选择时会覆盖rowNum参数传递到后台</param>
        /// <param name="pager">为 true 启用底部导航栏</param>
        /// <param name="topPager">为 true 启用顶部导航栏</param>
        /// <param name="pgButtons">为 true 显示翻页按钮</param>
        /// <param name="pgInput">为 true 显示翻页输入框</param>
        /// <param name="viewrecords">为 true 显示记录数信息</param>
        /// <param name="pagerPos">设置导航内容所在位置</param>
        /// <param name="recordPos">设置记录信息的位置</param>
        /// <param name="pgText">设置当前页信息,如: "Page {0} of {1}"</param>
        /// <param name="recordText">显示记录数信息。{0} 为记录数开始,{1}为记录数结束。viewrecords为ture时才能起效,且总记录数大于0时才会显示此信息</param>
        /// <returns></returns>
        public Grid SetPager(
            int page = 1, int rowNum = 20, int[] rowList = null,
            bool pager = true, bool topPager = false,
            bool pgButtons = true, bool pgInput = true, bool viewrecords = true,
            PagerPos pagerPos = PagerPos.Center, RecordPos recordPos = RecordPos.Right,
            string pgText = null, string recordText = null)
        {
            _page = page;
            _rowNum = rowNum;
            _rowList = rowList;
            _pager = pager;
            _topPager = topPager;
            _pgButtons = pgButtons;
            _pgInput = pgInput;
            _viewRecords = viewrecords;
            _pagerPos = pagerPos;
            _recordPos = recordPos;
            _pgText = pgText;
            _recordText = recordText;
            return this;
        }

        /// <summary>
        /// 定义一个class到一个列上用来显示列宽度调整时的效果
        /// </summary>
        /// <param name = "resizeClass"></param>
        /// <returns></returns>
        public Grid SetResizeClass(string resizeClass)
        {
            _resizeClass = resizeClass;
            return this;
        }

        /// <summary>
        /// 为ture则会在表格左边新增一列,显示行顺序号,从1开始递增。此列名为'rn'.
        /// </summary>
        /// <param name = "rowNumbers"></param>
        /// <param name = "rowNumWidth">设置行数列的宽度,如果rownumbers选项设置为true。(默认:25)</param>
        public Grid SetRowNumbers(bool rowNumbers = true, int rowNumWidth = 25)
        {
            _rowNumbers = rowNumbers;
            _rowNumWidth = rowNumWidth;
            return this;
        }

        /// <summary>
        ///     Determines how to post the data on which we perform searching.
        ///     When the this option is false the posted data is in key:value pair, if the option is true, the posted data is equal on those as in searchGrid method.
        ///     See here: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:advanced_searching#options
        ///     (default: true)
        /// </summary>
        /// <param name = "stringResult">Boolean indicating if</param>
        public Grid SetStringResult(bool stringResult = true)
        {
            _stringResult = stringResult;
            return this;
        }

        /// <summary>
        /// 创建一个动态滚动的表格,当为true时,翻页栏被禁用,使用垂直滚动条加载数据,且在首次访问服务器端时将加载所有数据到客户端。
        /// 当此参数为数字时,表格只控制可见的几行,所有数据都在这几行中加载
        /// </summary>
        /// <param name="virtualScroll"></param>
        /// <param name="justHoldVisibleLines">表示网格中的可见线应该在内存中存储(防止内存泄漏)</param>
        /// <param name="scrollOffset">设置垂直滚动条宽度,默认18</param>
        /// <param name="scrollRows">设置为true时,通过setSelection选中某行将会滚动表格使选中的行可见。
        /// 表格有水平滚动条,当使用表格编辑,通过上一条或者下一条导航按钮导向时将会很有用。</param>
        /// <param name="scrollTimeout">控制滚动事件延时时间,当scroll配置为1时有效</param>
        /// <returns></returns>
        public Grid SetScroll(bool justHoldVisibleLines = false, int scrollOffset = 18, bool scrollRows = false, int scrollTimeout = 200)
        {
            _scroll = true;
            if (justHoldVisibleLines)
            {
                _scrollInt = 1;
                _pager = false;
                _topPager = false;
                _scrollTimeout = scrollTimeout;
            }
            else
            {
                _scrollOffset = scrollOffset;
                _scrollRows = scrollRows;
            }
            return this;
        }

        /// <summary>
        /// 此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。
        /// 如果为false,则列宽度使用colModel指定的宽度,默认true
        /// </summary>
        /// <param name = "shrinkToFit"></param>
        public Grid SetShrinkToFit(bool shrinkToFit = true, int shrinkToFitInt = 0)
        {
            _shrinkToFit = shrinkToFit;
            if (shrinkToFit) _shrinkToFitInt = shrinkToFitInt;

            return this;
        }

        /// <summary>
        /// 启用或禁用排序功能
        /// </summary>
        /// <param name="sortable">为 true 时启用</param>
        /// <param name="sortName">排序列的名称,此参数会被传到后台</param>
        /// <param name="sortOrder">排序顺序,升序或者降序(asc or desc)</param>
        /// <param name="showAllSortIcons"></param>
        /// <param name="sortIconDirection"></param>
        /// <param name="sortOnHeaderClick"></param>
        /// <returns></returns>
        public Grid SetSort(bool sortable = true, string sortName = null, SortOrder sortOrder = SortOrder.Asc,
            bool showAllSortIcons = true, Direction sortIconDirection = Direction.Vertical, bool sortOnHeaderClick = true)
        {
            _sortable = sortable;
            _sortName = sortName;
            _sortOrder = sortOrder;
            _showAllSortIcons = showAllSortIcons;
            _sortIconDirection = sortIconDirection;
            return this;
        }

        /// <summary>
        /// 搜索设置
        /// </summary>
        /// <param name="searchOnEnter"></param>
        /// <param name="searchToolbar"></param>
        /// <param name="searchClearButton"></param>
        /// <param name="searchToggleButton"></param>
        /// <returns></returns>
        public Grid SetSearch(bool searchOnEnter, bool searchToolbar, bool searchClearButton, bool searchToggleButton)
        {
            _searchOnEnter = searchOnEnter;
            _searchToolbar = searchToolbar;
            _searchClearButton = searchClearButton;
            _searchToggleButton = searchToggleButton;
            return this;
        }

        /// <summary>
        /// 启用或禁用工具栏
        /// </summary>
        /// <param name = "toolbarPosition"></param>
        public Grid SetToolbar(ToolbarPosition toolbarPosition = ToolbarPosition.Top)
        {
            _toolbar = true;
            _toolbarPosition = toolbarPosition;
            return this;
        }

        /// <summary>
        ///  设置获取数据的地址
        /// </summary>
        /// <param name = "url"></param>
        public Grid SetUrl(string url)
        {
            _url = url;
            return this;
        }

        /// <summary>
        /// 如果设置则按此设置为主,如果没有设置则按colModel中定义的宽度计算
        /// </summary>
        /// <param name = "width">Width in pixels</param>
        public Grid SetWidth(int width)
        {
            _width = width;
            return this;
        }

        /// <summary>
        ///  用户数据是否在尾行上,默认值:(false)
        /// </summary>
        /// <param name = "userDataOnFooter"></param>
        public Grid SetUserDataOnFooter(bool userDataOnFooter = true)
        {
            _userDataOnFooter = userDataOnFooter;
            return this;
        }

        /// <summary>
        /// 启用或禁用树型表格
        /// </summary>
        /// <param name="treeGridModel"></param>
        /// <param name="rootLevel"></param>
        /// <returns></returns>
        public Grid SetTreeGrid(TreeGridModel treeGridModel = TreeGridModel.Adjacency, int rootLevel = 0)
        {
            _treeGrid = true;
            _treeRootLevel = 0;
            _treeGridModel = treeGridModel;
            return this;
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="rowAttr"></param>
        /// <returns></returns>
        public Grid SetRowAttr(string rowAttr)
        {
            _rowAttr = rowAttr;
            return this;
        }

        #endregion

        #region 事件

        /// <summary>
        ///     当插入行时触发。  参数:  'rowid','rowdata','rowelem' 。
        ///     rowid插入当前行的id;rowdata插入行的数据,格式为name: value,name为colModel中的名字。
        /// </summary>
        /// <param name = "onAfterInsertRow"></param>
        public Grid OnAfterInsertRow(string onAfterInsertRow)
        {
            _onAfterInsertRow = onAfterInsertRow;
            return this;
        }

        /// <summary>
        /// 向服务器端发起请求之前触发此事件但如果datatype是一个function时例外
        /// </summary>
        /// <param name = "onBeforeRequest"></param>
        public Grid OnBeforeRequest(string onBeforeRequest)
        {
            _onBeforeRequest = onBeforeRequest;
            return this;
        }

        /// <summary>
        /// 当用户点击当前行在未选择此行时触发。rowid:此行id;e:事件对象。返回值为ture或者false。
        /// 如果返回true则选择完成,如果返回false则不会选择此行也不会触发其他事件
        /// </summary>
        /// <param name = "onBeforeSelectRow"></param>
        public Grid OnBeforeSelectRow(string onBeforeSelectRow)
        {
            _onBeforeSelectRow = onBeforeSelectRow;
            return this;
        }

        /// <summary>
        /// 当表格所有数据都加载完成而且其他的处理也都完成时触发此事件,排序,翻页同样也会触发此事件,参数无
        /// </summary>
        /// <param name = "onGridComplete"></param>
        public Grid OnGridComplete(string onGridComplete)
        {
            _onGridComplete = onGridComplete;
            return this;
        }

        /// <summary>
        ///
        ///     'xhr': The XMLHttpRequest
        /// </summary>
        /// <param name = "onLoadBeforeSend"></param>
        public Grid OnLoadBeforeSend(string onLoadBeforeSend)
        {
            _onLoadBeforeSend = onLoadBeforeSend;
            return this;
        }

        /// <summary>
        /// 当从服务器返回响应时执行,xhr:XMLHttpRequest 对象
        ///     'xhr': The XMLHttpRequest
        /// </summary>
        /// <param name = "onLoadComplete"></param>
        public Grid OnLoadComplete(string onLoadComplete)
        {
            _onLoadComplete = onLoadComplete;
            return this;
        }

        /// <summary>
        ///    如果请求服务器失败则调用此方法。xhr:XMLHttpRequest 对象;satus:错误类型,字符串类型;error:exception对象
        ///     'xhr': The XMLHttpRequest
        ///     'status': String describing the type of error
        ///     'error': Optional exception object, if one occurred
        /// </summary>
        /// <param name = "onLoadError"></param>
        public Grid OnLoadError(string onLoadError)
        {
            _onLoadError = onLoadError;
            return this;
        }

        /// <summary>
        ///    当点击单元格时触发。rowid:当前行id;iCol:当前单元格索引;cellContent:当前单元格内容;e:event对象
        ///     Variables available in call:
        ///     'rowid': The id of the row
        ///     'iCol': The index of the cell,
        ///     'cellcontent': The content of the cell,
        ///     'e': The event object element where we click.
        ///     (Be aware that this available when we are not using cell editing module
        ///     and is disabled when using cell editing).
        /// </summary>
        /// <param name = "onCellSelect"></param>
        public Grid OnCellSelect(string onCellSelect)
        {
            _onCellSelect = onCellSelect;
            return this;
        }

        /// <summary>
        ///    双击行时触发。rowid:当前行id;iRow:当前行索引位置;iCol:当前单元格位置索引;e:event对象
        ///     Variables available in call:
        ///     'rowid': The id of the row,
        ///     'iRow': The index of the row (do not mix this with the rowid),
        ///     'iCol': The index of the cell.
        ///     'e': The event object
        /// </summary>
        /// <param name = "onDblClickRow"></param>
        public Grid OnDblClickRow(string onDblClickRow)
        {
            _onDblClickRow = onDblClickRow;
            return this;
        }

        /// <summary>
        ///    当点击显示/隐藏表格的那个按钮时触发;gridstate:表格状态,可选值:visible or hidden
        ///     Variables available in call:
        ///     'gridstate': The state of the grid - can have two values - visible or hidden
        /// </summary>
        /// <param name = "onHeaderClick"></param>
        public Grid OnHeaderClick(string onHeaderClick)
        {
            _onHeaderClick = onHeaderClick;
            return this;
        }

        /// <summary>
        ///     点击翻页按钮填充数据之前触发此事件,同样当输入页码跳转页面时也会触发此事件
        ///     Variables available in call:
        ///     'pgButton': first,last,prev,next in case of button click, records in case when
        ///     a number of requested rows is changed and user when the user change the number of the requested page
        /// </summary>
        /// <param name = "onPaging"></param>
        public Grid OnPaging(string onPaging)
        {
            _onPaging = onPaging;
            return this;
        }

        /// <summary>
        ///    在行上右击鼠标时触发此事件。rowid:当前行id;iRow:当前行位置索引;iCol:当前单元格位置索引;e:event对象
        ///     Variables available in call:
        ///     'rowid': The id of the row,
        ///     'iRow': The index of the row (do not mix this with the rowid),
        ///     'iCol': The index of the cell.
        ///     'e': The event object
        ///     Warning - this event does not work in Opera browsers, since Opera does not support oncontextmenu event
        /// </summary>
        /// <param name = "onRightClickRow"></param>
        public Grid OnRightClickRow(string onRightClickRow)
        {
            _onRightClickRow = onRightClickRow;
            return this;
        }

        /// <summary>
        ///     multiselect为ture,且点击头部的checkbox时才会触发此事件。aRowids:所有选中行的id集合,为一个数组。
        ///     status:boolean变量说明checkbox的选择状态,true选中false不选中。无论checkbox是否选择,aRowids始终有 值
        ///     Variables available in call:
        ///     'aRowids':  Array of the selected rows (rowid's).
        ///     'status': Boolean variable determining the status of the header check box - true if checked, false if not checked.
        ///     Be awareS that the aRowids alway contain the ids when header checkbox is checked or unchecked.
        /// </summary>
        /// <param name = "onSelectAll"></param>
        public Grid OnSelectAll(string onSelectAll)
        {
            _onSelectAll = onSelectAll;
            return this;
        }

        /// <summary>
        ///     当选择行时触发此事件。rowid:当前行id;status:选择状态,当multiselect 为true时此参数才可用
        ///     Variables available in function call:
        ///     'rowid': The id of the row,
        ///     'status': Tthe status of the selection. Can be used when multiselect is set to true.
        ///     true if the row is selected, false if the row is deselected.
        ///     <param name = "onSelectRow"></param>
        /// </summary>
        public Grid OnSelectRow(string onSelectRow)
        {
            _onSelectRow = onSelectRow;
            return this;
        }

        /// <summary>
        ///     当点击排序列但是数据还未进行变化时触发此事件。
        ///     index:name在colModel中位置索引;iCol:当前单元格位置索引;sortorder:排序状态:desc或者asc
        ///     Variables available in call:
        ///     'index': The index name from colModel
        ///     'iCol': The index of column,
        ///     'sortorder': The new sorting order - can be 'asc' or 'desc'.
        ///     If this event returns 'stop' the sort processing is stopped and you can define your own custom sorting
        /// </summary>
        /// <param name = "onSortCol"></param>
        public Grid OnSortCol(string onSortCol)
        {
            _onSortCol = onSortCol;
            return this;
        }

        /// <summary>
        ///     当开始改变一个列宽度时触发此事件。event:event对象;index:当前列在colModel中位置索引
        ///     Variables available in call:
        ///     'event':  The event object
        ///     'index': The index of the column in colModel.
        /// </summary>
        /// <param name = "onResizeStart"></param>
        public Grid OnResizeStart(string onResizeStart)
        {
            _onResizeStart = onResizeStart;
            return this;
        }

        /// <summary>
        ///    当列宽度改变之后触发此事件。newwidth:列改变后的宽度;index:当前列在colModel中的位置索引
        ///     Variables available in call:
        ///     'newwidth': The new width of the column
        ///     'index': The index of the column in colModel.
        /// </summary>
        /// <param name = "onResizeStop"></param>
        public Grid OnResizeStop(string onResizeStop)
        {
            _onResizeStop = onResizeStop;
            return this;
        }

        /// <summary>
        ///    向服务器发起请求时会把数据进行序列化,用户自定义数据也可以被提交到服务器端
        ///     Variables available in call:
        ///     'postData': Posted data
        /// </summary>
        /// <param name = "onSerializeGridData"></param>
        public Grid OnSerializeGridData(string onSerializeGridData)
        {
            _onSerializeGridData = onSerializeGridData;
            return this;
        }
        #endregion

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string RenderJavascript()
        {
            var script = new StringBuilder();

            if (_asyncLoad)
                script.Append("jQuery(window).ready(function () {");
            else
                script.Append("jQuery(document).ready(function () {");

            script.AppendFormat("jQuery('#{0}').jqGrid('GridDestroy')", _id);
            if (_pager == true)
            {
                script.AppendFormat(".after('<div id=\"{0}_pager\"></div>')", _id);
            }
            if (_topPager == true)
            {
                script.AppendFormat(".after('<div id=\"{0}_toppager\"></div>')", _id);
            }
            script.Append(".jqGrid({");

            // 确保最多只有一个键
            if (_columns.Count(r => r.IsKey) > 1)
            {
                throw new ArgumentException("添加过多的键列。最大允许为1。");
            }
            if (_grouping && _groupingView == null)
            {
                throw new ArgumentNullException("启用分组必须设置 groupingView!");
            }

            if (!_altClass.IsEmpty()) script.AppendFormat("altclass:'{0}',", _altClass);
            if (_altRows) script.Append("altRows:true,");
            if (_autoEncode) script.Append("autoencode:true,");
            if (_autoWidth) script.Append("autowidth:true,");
            if (!_caption.IsEmpty()) script.AppendFormat("caption:'{0}',", _caption);
            if (_cellLayout != 5) script.AppendFormat("cellLayout:{0},", _cellLayout);

            if (_cellEdit)
            {
                script.Append("cellEdit:true,");
                if (_cellsubmit == SubmitType.Remote)
                {
                    script.AppendFormat("cellurl:'{0}',", _cellurl);
                }
                else
                {
                    script.AppendFormat("cellsubmit:'{0}',", _cellsubmit.ToString().ToLower());
                }
            }

            // Datatype
            script.Append(_treeGrid ? $"treedatatype:'{_dataType.ToString().ToLower()}'," : $"datatype:'{_dataType.ToString().ToLower()}',");

            if (_deepempty) script.Append("deepempty:true,");
            if (_deselectAfterSort == false && _dataType == DataType.Local) script.Append("deselectAfterSort:false,");
            if (!_editurl.IsEmpty()) script.AppendFormat("editurl:'{0}',", _editurl);
            if (!_emptyRecords.IsEmpty()) script.AppendFormat("emptyrecords:'{0}',", _emptyRecords);
            if (_footerRow) script.Append("footerrow:true,");
            if (_forceFit) script.Append("forceFit:true,");
            if (_gridstate != GridState.Visible) script.AppendFormat("footerrow:'{0}',", _gridstate.ToString().ToLower());
            if (_gridView) script.Append("gridView:true,");
            if (_grouping) script.AppendFormat("grouping:true,{0},", _groupingView.ToString());
            if (_headerTitles) script.Append("headertitles:true,");

            if (_height != 150)
            {
                if (_scroll && _scrollInt == 1) script.AppendFormat("height:'{0}',", "100%");
                else script.AppendFormat("height:{0},", _height);
            }
            if (_hiddenGrid) script.Append("hiddengrid:true,");
            if (!_hideGrid) script.Append("hidegrid:false,");
            if (!_hoverRows) script.Append("hoverrows:false,");
            if (_ignoreCase) script.Append("ignoreCase:true,");

            if (_jsonReader != null && _dataType == DataType.Json)
            {
                script.Append("jsonReader:{'repeatitems':" + _jsonReader.RepeatItems.ToString().ToLower() + ", 'id': '" + _jsonReader.Id + "' },");
            }

            if (_loadonce) script.Append("loadonce:true,");
            if (!_loadtext.IsEmpty()) script.AppendFormat("loadtext:'{0}',", _loadtext);
            if (_loadui != LoadUi.Enable) script.AppendFormat("loadui:'{0}',", _loadui.ToString().ToLower());
            if (_mtype != RequestType.Get) script.AppendFormat("mtype:'{0}',", _mtype.ToString().ToUpper());

            if (_multiSelect)
            {
                script.Append("multiselect:true,");
                if (_multiboxOnly) script.Append("multiboxonly:true,");
                if (_multiKey != MultiKey.None) script.AppendFormat("multikey:'{0}',", _multiKey.ToString().ToLower());
                if (_multiSelectWidth != 20) script.AppendFormat("multiselectWidth:{0},", _multiSelectWidth);
            }

            if (_multiSort) script.Append("multiSort:true,");

            if (_pager || _topPager)
            {
                if (_page != 1) script.AppendFormat("page:{0},", _page);
                if (_rowList != null) script.AppendFormat("rowList:[{0}],", _rowList.Join());
                if (_rowNum != 20) script.AppendFormat("rowNum:{0},", _rowNum);
                if (_pager) script.AppendFormat("pager:'#{0}_pager',", _id);
                if (_topPager) script.AppendFormat("topPager:'#{0}_toppager',", _id);
                if (_pagerPos != PagerPos.Center) script.AppendFormat("pagerpos:'{0}',", _pagerPos.ToString().ToLower());
                if (_recordPos != RecordPos.Right) script.AppendFormat("recordpos:'{0}',", _recordPos.ToString().ToLower());
                if (!_pgButtons) script.Append("pgbuttons:false,");
                if (!_pgInput) script.Append("pginput:false,");
                if (!_viewRecords) script.Append("viewRecords:false,");
                if (!_pgText.IsEmpty()) script.AppendFormat("pgtext:'{0}',", _pgText);
                if (!_recordText.IsEmpty() && _viewRecords) script.AppendFormat("recordtext:'{0}',", _recordText);
            }

            if (!_resizeClass.IsEmpty()) script.AppendFormat("resizeclass:'{0}',", _resizeClass);

            if (_rowNumbers)
            {
                script.Append("rownumbers:true,");
                if (_rowNumWidth != 20) script.AppendFormat("rownumWidth:{0},", _rowNumWidth);
            }

            if (_scrollInt == 1)
            {
                script.Append("scroll:1,");
                if (_scrollTimeout != 200) script.AppendFormat("scrollTimeout:{0},", _scrollTimeout);
            }
            if (_scroll)
            {
                script.Append("scroll:true,");
                if (_scrollOffset != 18) script.AppendFormat("scrollOffset:{0},", _scrollOffset);
                if (_scrollRows) script.Append("scrollrows:true,");
            }

            if (_sortable)
            {
                script.Append("sortable:true,");
                if (!_sortName.IsEmpty()) script.AppendFormat("sortname:'{0}',", _sortName);
                if (_sortOrder != SortOrder.Asc) script.AppendFormat("sortorder:'{0}',", _sortOrder.ToString().ToLower());
                if (_showAllSortIcons.HasValue || _sortIconDirection.HasValue || _sortOnHeaderClick.HasValue)
                {
                    if (!_showAllSortIcons.HasValue) _showAllSortIcons = false;
                    if (!_sortIconDirection.HasValue) _sortIconDirection = Direction.Vertical;
                    if (!_sortOnHeaderClick.HasValue) _sortOnHeaderClick = true;

                    script.AppendFormat("viewsortcols:[{0},'{1}',{2}],",
                        _showAllSortIcons.ToString().ToLower(),
                        _sortIconDirection.ToString().ToLower(),
                        _sortOnHeaderClick.ToString().ToLower());
                }
            }

            if (!_shrinkToFit) script.Append("shrinkToFit:false,");
            else if (_shrinkToFitInt > 0) script.AppendFormat("shrinkToFit:{0},", _shrinkToFitInt);

            if (_toolbar) script.AppendFormat("toolbar:[{0},'{1}'],", _toolbar.ToString().ToLower(), _toolbarPosition.ToString().ToLower());
            if (!_url.IsEmpty()) script.AppendFormat("url:'{0}',", _url);
            if (_width.HasValue) script.AppendFormat("width:'{0}',", _width);

            if (_treeGrid)
            {
                if (_columns.Count(r => r.IsExpandable) > 1)
                {
                    throw new ArgumentException("最多只允许一个列设置为 IsExpandable=true");
                }
                var keyColumn = _columns.FirstOrDefault(r => r.IsKey);
                var expandableColumn = _columns.FirstOrDefault(r => r.IsExpandable);
                if (keyColumn == null)
                {
                    throw new ArgumentException("必须设置一个列的 IsKey=true");
                }
                if (expandableColumn == null)
                {
                    throw new ArgumentException("必须设置一个列的 IsExpandable=true");
                }

                script.Append("treeGrid: true,");
                script.AppendFormat("ExpandColumn : '{0}',", expandableColumn.Name);
                script.AppendFormat("treeGridModel : '{0}',", _treeGridModel.ToString().ToLower());
                script.AppendFormat("tree_root_level : {0},", _treeRootLevel);
            }

            if (_userDataOnFooter)
                script.AppendFormat("userDataOnFooter:{0},", _footerRow.ToString().ToLower());
            else if (!_onBeforeRequest.IsEmpty())
                script.AppendFormat("beforeRequest: {0},", _onBeforeRequest);   // function() {{{0}}}

            if (!_onAfterInsertRow.IsEmpty())
                script.AppendFormat("afterInsertRow:{0},", _onAfterInsertRow);  // function(rowid, rowdata, rowelem) {{{0}}}

            if (_columns.Any(x => x.HasDefaultSearchValue))
            {
                #region jqGrid javascript onbefore request hack

                var defaultValueColumns = _columns
                    .Where(x => x.HasDefaultSearchValue)
                    .Select(x => new { field = x.Index, op = x.SearchOption, data = x.DefaultSearchValue });

                var onbeforeRequestHack = @"
                function() {
                        var defaultValueColumns = " + defaultValueColumns.ToJson() + @";
                        var colModel = this.p.colModel;

                        if (defaultValueColumns.length > 0) {
                            var postData = this.p.postData;

                            var filters = {};

                            if (postData.hasOwnProperty('filters')) {
                                filters = JSON.parse(postData.filters);
                            }

                            var rules = [];

                            if (filters.hasOwnProperty('rules')) {
                                rules = filters.rules;
                            }

                            $.each(defaultValueColumns, function (defaultValueColumnIndex, defaultValueColumn) {
                                $.each(rules, function (index, rule) {
                                    if (defaultValueColumn.field == rule.field) {
                                        delete rules[index];
                                        return;
                                    }
                                });

                                rules.push(defaultValueColumn);
                            });

                            filters.groupOp = 'AND';
                            filters.rules = rules;

                            postData._search = true;
                            postData.filters = JSON.stringify(filters);

                            $(this).setGridParam({ search: true, 'postData': postData});
                        }

                        this.p.beforeRequest = function() { " + ((!_onBeforeRequest.IsEmpty()) ? _onBeforeRequest : "") + @" };
                        this.p.beforeRequest.call(this);
                    } ";

                #endregion jqGrid javascript onbefore request hack
                script.AppendFormat("beforeRequest: {0},", onbeforeRequestHack);
            }

            if (!_onBeforeSelectRow.IsEmpty())
                script.AppendFormat("beforeSelectRow: {0},", _onBeforeSelectRow);   //function(rowid, e) {{{0}}}

            if (!_onGridComplete.IsEmpty())
                script.AppendFormat("gridComplete: {0},", _onGridComplete); //function() {{{0}}}

            if (!_onLoadBeforeSend.IsEmpty())
                script.AppendFormat("loadBeforeSend:{0},", _onLoadBeforeSend);  // function(xhr, settings) {{{0}}}

            if (!_onLoadComplete.IsEmpty())
                script.AppendFormat("loadComplete:{0},", _onLoadComplete);  // function(xhr) {{{0}}}

            if (!_onLoadError.IsEmpty())
                script.AppendFormat("loadError:{0},", _onLoadError);    // function(xhr, status, error) {{{0}}}

            if (!_onCellSelect.IsEmpty())
                script.AppendFormat("onCellSelect: {0},", _onCellSelect);   //function(rowid, iCol, cellcontent, e) {{{0}}}

            if (!_onDblClickRow.IsEmpty())
                script.AppendFormat("ondblClickRow:{0},", _onDblClickRow);  // function(rowid, iRow, iCol, e) {{{0}}}

            if (!_onHeaderClick.IsEmpty())
                script.AppendFormat("onHeaderClick: {0},", _onHeaderClick); //function(gridstate) {{{0}}}

            if (!_onPaging.IsEmpty())
                script.AppendFormat("onPaging:{0},", _onPaging);    // function(pgButton) {{{0}}}

            if (!_onRightClickRow.IsEmpty())
                script.AppendFormat("onRightClickRow: {0},", _onRightClickRow); //function(rowid, iRow, iCol, e) {{{0}}}

            if (!_onSelectAll.IsEmpty())
                script.AppendFormat("onSelectAll: {0},", _onSelectAll); //function(aRowids, status) {{{0}}}

            if (!_onSelectRow.IsEmpty())
                script.AppendFormat("onSelectRow: {0},", _onSelectRow); //function(rowid, status) {{{0}}}

            if (!_onSortCol.IsEmpty())
                script.AppendFormat("onSortCol:{0},", _onSortCol);  // function(index, iCol, sortorder) {{{0}}}

            if (!_onResizeStart.IsEmpty())
                script.AppendFormat("resizeStart: {0},", _onResizeStart);   // function(jqGridEvent, index) {{{0}}}

            if (!_onResizeStop.IsEmpty())
                script.AppendFormat("resizeStop: {0},", _onResizeStop); //function(newwidth, index) {{{0}}}

            if (!_onSerializeGridData.IsEmpty())
                script.AppendFormat("serializeGridData: {0},", _onSerializeGridData);   // function(postData) {{{0}}}

            if (!_rowAttr.IsEmpty())
                script.AppendFormat("rowattr:{0},", _rowAttr);  // function(rd) {{{0}}}

            script.Append("colModel: [");
            script.Append(_columns.Join());
            script.Append("]");

            script.Append("});");

            if (_searchToolbar == true && _pager &&
                (_searchClearButton.HasValue && _searchClearButton == true || _searchToggleButton.HasValue && _searchToggleButton == true))
            {
                script.Append("jQuery('#" + _id + "').jqGrid('navGrid',\"#" + _pager + "\",{edit:false,add:false,del:false,search:false,refresh:false}); ");
            }

            if (_searchToolbar == true && _searchClearButton.HasValue && _pager &&
                _searchClearButton == true)
            {
                script.Append("jQuery('#" + _id + "').jqGrid('navButtonAdd',\"#" + _pager +
                                 "\",{caption:\"Clear\",title:\"Clear Search\",buttonicon :'ui-icon-refresh', onClickButton:function(){jQuery('#" + _id + "')[0].clearToolbar(); }}); ");
            }

            if (_searchToolbar == true && _searchToggleButton.HasValue && _pager && _searchToggleButton == true)
            {
                script.Append("jQuery('#" + _id + "').jqGrid('navButtonAdd',\"#" + _pager +
                              "\",{caption:\"Toggle Search\",title:\"Toggle Search\",buttonicon :'ui-icon-refresh', onClickButton:function(){jQuery('#" + _id + "')[0].toggleToolbar(); }}); ");
            }

            if (_searchToolbar == true)
            {
                script.Append("jQuery('#" + _id + "').jqGrid('filterToolbar', {stringResult:" + _stringResult.ToString().ToLower());
                if (_searchOnEnter.HasValue)
                    script.AppendFormat(", searchOnEnter:{0}", _searchOnEnter.ToString().ToLower());
                script.Append("});");
            }

            script.Append("});");

            script.Replace("##gridid##", _id);

            return script.ToString();
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        //public string RenderHtmlElements()
        //{
        //    var table = new StringBuilder();
        //    return table.ToString();
        //}
        /// <summary>
        /// 创建 jqGrid 的HTML和SCRIPT
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var script = new StringBuilder();
            //script.Append("<script type=\"text/javascript\">");
            script.Append(RenderJavascript());
            //script.Append("</script>");

            script.Replace("##gridid##", _id);

            return script.ToString();
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string ToHtmlString()
        {
            return ToString();
        }
    }
}


text:
.. _class-example:

doxygenclass Directive
======================

This directive generates the appropriate output for a single class. It takes the
standard ``project``, ``path``, ``outline`` and ``no-link`` options and
additionally the ``members``, ``protected-members``, ``private-members`` and
``undoc-members`` options.

``members``
   Designed to behavior in a similar manner to the ``members`` option for the
   ``autoclass`` directive that comes with the Sphinx ``autodoc`` extension.

   If you do not specify this option you will not get any information about the
   class members, just the general class documentation. If you provide it
   without arguments, then Breathe adds all the public members and their
   documentation.  If you specify it with **comma separated** arguments, then
   Breathe will treat the arguments as names of members and provide
   documentation for only those members that have been named.

``protected-members``
   If specified, the protected members of the class will be displayed.

``private-members``
   If specified, the private members of the class will be displayed.

``undoc-members``
   If specified, the undocumented members of the class will be displayed.

If you would like to always specify some combination of ``members``,
``protected-members``, ``private-members`` and ``undoc-members`` then you can
use the :ref:`breathe_default_members <breathe-default-members>` configuration
variable to set it in the ``conf.py``.

The output includes references to any base classes and derived classes of the
specified class.

.. contents::

Basic Example
-------------

This displays the class documentation without any members:

.. code-block:: rst

   .. doxygenclass:: Nutshell
      :project: nutshell

It produces this output:

.. doxygenclass:: Nutshell
   :project: nutshell
   :no-link:

Template Specialisation Example
-------------------------------

You can reference class template specialisations by include the specialisation
in the name:

.. code-block:: rst

   .. doxygenclass:: TemplateClass< T * >
      :project: template_specialisation

Produces this output:

.. doxygenclass:: TemplateClass< T * >
   :project: template_specialisation
   :no-link:

Where as without the specialisation, the directive references the generic
declaration:

.. code-block:: rst

   .. doxygenclass:: TemplateClass
      :project: template_specialisation

Produces this output:

.. doxygenclass:: TemplateClass
   :project: template_specialisation
   :no-link:

Members Example
---------------

This directive call will display the class documentation with all the public
members:

.. code-block:: rst

   .. doxygenclass:: Nutshell
      :project: nutshell
      :members:

It produces this output:

.. doxygenclass:: Nutshell
   :project: nutshell
   :members:
   :no-link:

Specific Members Example
------------------------

This displays the class documentation with only the members listed in the
``:members:`` option:

.. code-block:: rst

   .. doxygenclass:: Nutshell
      :project: nutshell
      :members: crack, isCracked

It produces this output:

.. doxygenclass:: Nutshell
   :project: nutshell
   :members: crack, isCracked
   :no-link:

Protected Members
-----------------

This displays only the protected members of the class. Normally this is combined
with the ``:members:`` option to show the public members as well.

.. code-block:: rst

   .. doxygenclass:: GroupedClassTest
      :project: group
      :protected-members:

It produces this output:

.. doxygenclass:: GroupedClassTest
   :project: group
   :protected-members:
   :no-link:

Private Members
---------------

This displays only the private members of the class. Normally this is combined
with the ``:members:`` option to show the public members as well.

.. code-block:: rst

   .. doxygenclass:: Nutshell
      :project: nutshell
      :private-members:

It produces this output:

.. doxygenclass:: Nutshell
   :project: nutshell
   :private-members:
   :no-link:

Undocumented Members
--------------------

This displays the undocumented members of the class which are suppressed by
default. Undocumented public members are only shown if the ``:members:`` option
is also used. The same goes for the undocumented private members and the
``private-members`` option.

.. code-block:: rst

   .. doxygenclass:: ClassTest
      :project: class
      :members:
      :private-members:
      :undoc-members:

It produces this output:

.. doxygenclass:: ClassTest
   :project: classtest
   :members:
   :private-members:
   :undoc-members:
   :no-link:

.. note::

   Undocumented classes are still not shown in the output due to an implementation
   issue. Please post an issue on github if you would like this resolved.

Outline Example
---------------

This displays only the names of the class members and not their
documentation. The ``:members:`` and ``:private-members:`` options determine
which members are displayed.

.. code-block:: rst

   .. doxygenclass:: Nutshell
      :project: nutshell
      :members:
      :outline:

It produces this output:

.. doxygenclass:: Nutshell
   :project: nutshell
   :members:
   :outline:
   :no-link:

Qt Slots Example
----------------

Doxygen is aware of Qt Slots and so Breathe can pick them up and display them in
the output. They are displayed in appropriate ``Public Slots``, ``Protected
Slots`` and ``Private Slots`` sections.

.. code-block:: rst

   .. doxygenclass:: QtSlotExample
      :project: qtslots
      :members:

Produces the following output:

.. doxygenclass:: QtSlotExample
   :project: qtslots
   :members:
   :no-link:

Failing Example
---------------

This intentionally fails:

.. code-block:: rst

   .. doxygenclass:: made_up_class
      :project: class
      :members:

It produces the following warning message:

.. warning:: doxygenclass: Cannot find class "made_up_class" in doxygen xml
   output for project "class" from directory: ../../examples/doxygen/class/xml/

redpajama_set_name: RedPajamaGithub


text:
<#import "/views/sso/admin/layout/adminLayout.ftl.html" as layout />
<#global _mainMenuPage = 'statistics' />
<#global _jsIncludeChartsLibrary = true />
<@layout.adminLayout i18n("adminUsers")>

${i18n("adminAppStatistics")} ${i18n("adminAppStatisticsLast5Minutes")}

</@layout.adminLayout>


text:
'use strict';
/**
 * Developed by Engagement Lab, 2019
 * ==============
 * Route to retrieve data by url
 * @class api
 * @author Johnny Richardson
 *
 * ==========
 */
const keystone =  global.keystone,
    mongoose = require('mongoose'),
    Bluebird = require('bluebird'),
    _ = require('underscore');

mongoose.Promise = require('bluebird');

var buildData = (res) => {

    let list = keystone.list('Files').model;
    let allFields = [];
    let fields = ['guide', 'zip', 'storybook1', 'storybook2', 'storybook3', 'storybook4', 'poster1', 'poster2', 'poster3', 'poster4'];
    let imgFields = ['guideImg', 'storybook1Img', 'storybook2Img', 'storybook3Img', 'storybook4Img', 'poster1Img', 'poster2Img', 'poster3Img', 'poster4Img'];

    _.each(fields, (f) => {
       allFields.push(f + 'En.url');
       allFields.push(f + 'Tm.url');
       allFields.push(f + 'Hi.url');
    });
    _.each(imgFields, (f) => {
       allFields.push(f + 'En.public_id');
       allFields.push(f + 'Tm.public_id');
       allFields.push(f + 'Hi.public_id');
    });

    let data = list.findOne({}, allFields);

    Bluebird.props({
            jsonData: data
        })
        .then(results => {
            return res.status(200).json({
                status: 200,
                data: results.jsonData
            });
        }).catch(err => {
            console.log(err);
        })

}

/*
 * Get data
 */
exports.get = function (req, res) {

    let lang = null;
    if (req.params.lang)
        lang = req.params.lang;

    return buildData(res, lang);

}


text:
from distutils.core import setup
import os
import setuplib

packages, package_data = setuplib.find_packages('towel_bootstrap')

setup(name='towel-bootstrap',
    version=__import__('towel_bootstrap').__version__,
    description='Keeping you DRY since 2010',
    long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read().decode('utf-8'),
    author='Matthias Kestenholz',
    author_email='mk@feinheit.ch',
    url='http://github.com/matthiask/towel-bootstrap/',
    license='BSD License',
    platforms=['OS Independent'],
    packages=packages,
    package_data=package_data,
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Environment :: Web Environment',
        'Framework :: Django',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
        'Topic :: Software Development',
        'Topic :: Software Development :: Libraries :: Application Frameworks',
    ],
)


text:
package org.osgi.annotation.versioning;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * A type implemented by the Provider Role.
 *
 *

 * A non-binary compatible change to a provider type normally requires
 * incrementing the minor version of the type's package. This change will
 * require all providers to be updated to handle the change, but consumers of
 * that package will not require changes since they only use, and do not
 * implement, the provider type.
 *
 *

 * A type can be marked {@link ConsumerType} or {@link ProviderType} but not
 * both. A type is assumed to be {@link ConsumerType} it is not marked either
 * {@link ConsumerType} or {@link ProviderType}.
 *
 *

 * This annotation is not retained at runtime. It is for use by tools to
 * understand the semantic version of a package. When a bundle implements a
 * provider type from an imported package, then the bundle's import range for
 * that package must require the package's exact major and minor version.
 *
 * @see Semantic Versioning
 * @author $Id: 61f1a53ed24d7fdb8944b47fcae42414ac63a48b $
 */
@Documented
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface ProviderType {
	// marker annotation
}


text:
Properties::Properties(QWidget *parent) : QDialog(parent),ui(new Ui::Properties)
{
    ui->setupUi(this);

    ui->inputPhoneColor->setCurrentText(phone.color);
    ui->inputParaboloidColor->setCurrentText(paraboloid.color);
    ui->inputUserColor->setCurrentText(user.color);
    ui->inputBackgroundColor->setCurrentText(background.color);

    ui->inputPhoneOpacity->setText(QString::number(phone.alpha));
    ui->inputParaboloidOpacity->setText(QString::number(paraboloid.alpha));
    ui->inputUserOpacity->setText(QString::number(user.alpha));
    ui->inputBackgroudOpacity->setText(QString::number(background.alpha));
}

Properties::~Properties()
{
    delete ui;
}

void Properties::on_buttonAccept_clicked()
{
    paraboloid.setColor(ui->inputParaboloidColor->currentText(), ui->inputParaboloidOpacity->text());
    phone.setColor(ui->inputPhoneColor->currentText(), ui->inputPhoneOpacity->text());
    user.setColor(ui->inputUserColor->currentText(), ui->inputUserOpacity->text());
    background.setColor(ui->inputBackgroundColor->currentText(), ui->inputBackgroudOpacity->text());
}


text:
namespace ash {
namespace {

// Global lock screen instance. There can only ever be on lock screen at a
// time.
LockScreen* instance_ = nullptr;

}  // namespace

LockScreen::TestApi::TestApi(LockScreen* lock_screen)
    : lock_screen_(lock_screen) {}

LockScreen::TestApi::~TestApi() = default;

LockContentsView* LockScreen::TestApi::contents_view() const {
  return lock_screen_->contents_view_;
}

void LockScreen::TestApi::AddOnShownCallback(base::OnceClosure on_shown) {
  if (lock_screen_->is_shown_) {
    std::move(on_shown).Run();
    return;
  }
  lock_screen_->on_shown_callbacks_.push_back(std::move(on_shown));
}

LockScreen::LockScreen(ScreenType type) : type_(type) {
  auto* active_window = window_util::GetActiveWindow();
  if (active_window) {
    auto* active_widget =
        views::Widget::GetWidgetForNativeWindow(active_window);
    if (active_widget)
      paint_as_active_lock_ = active_widget->LockPaintAsActive();
  }

  tray_action_observation_.Observe(Shell::Get()->tray_action());
  if (Shell::Get()->session_controller()->GetSessionState() !=
      session_manager::SessionState::LOGIN_SECONDARY) {
    saved_clipboard_ = ui::Clipboard::TakeForCurrentThread();
  }
}

LockScreen::~LockScreen() {
  widget_.reset();

  if (Shell::Get()->session_controller()->GetSessionState() !=
      session_manager::SessionState::LOGIN_SECONDARY) {
    ui::Clipboard::DestroyClipboardForCurrentThread();
    if (saved_clipboard_)
      ui::Clipboard::SetClipboardForCurrentThread(std::move(saved_clipboard_));
  }
}

std::unique_ptr<views::View> LockScreen::MakeContentsView() {
  auto initial_note_action_state =
      Shell::Get()->tray_action()->GetLockScreenNoteState();
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kShowLoginDevOverlay)) {
    auto debug_view =
        std::make_unique<LockDebugView>(initial_note_action_state, type_);
    contents_view_ = debug_view->lock();
    return debug_view;
  }

  auto detachable_base_model =
      LoginDetachableBaseModel::Create(Shell::Get()->detachable_base_handler());
  auto view = std::make_unique<LockContentsView>(
      initial_note_action_state, type_,
      Shell::Get()->login_screen_controller()->data_dispatcher(),
      std::move(detachable_base_model));
  contents_view_ = view.get();
  return view;
}

// static
LockScreen* LockScreen::Get() {
  CHECK(instance_);
  return instance_;
}

// static
void LockScreen::Show(ScreenType type) {
  CHECK(!instance_);
  // Capture should be released when locked.
  ::wm::CaptureController::Get()->SetCapture(nullptr);

  instance_ = new LockScreen(type);

  aura::Window* parent = nullptr;
  if (Shell::HasInstance()) {
    parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
                                 kShellWindowId_LockScreenContainer);
  }
  instance_->widget_ =
      CreateLockScreenWidget(parent, instance_->MakeContentsView());
  instance_->widget_->SetBounds(
      display::Screen::GetScreen()->GetPrimaryDisplay().bounds());

  // Postpone showing the screen after the animation of the first wallpaper
  // completes, to make the transition smooth. The callback will be dispatched
  // immediately if the animation is already complete (e.g. kLock).
  Shell::Get()->wallpaper_controller()->AddFirstWallpaperAnimationEndCallback(
      base::BindOnce(&LockScreen::ShowWidgetUponWallpaperReady),
      instance_->widget_->GetNativeView());
}

// static
bool LockScreen::HasInstance() {
  return !!instance_;
}

void LockScreen::Destroy() {
  Shell::Get()->login_screen_controller()->OnLockScreenDestroyed();
  CHECK_EQ(instance_, this);

  Shell::Get()->login_screen_controller()->data_dispatcher()->RemoveObserver(
      Shelf::ForWindow(Shell::GetPrimaryRootWindow())
          ->shelf_widget()
          ->login_shelf_view());

  delete instance_;
  instance_ = nullptr;
}

void LockScreen::FocusNextUser() {
  contents_view_->FocusNextUser();
}

void LockScreen::FocusPreviousUser() {
  contents_view_->FocusPreviousUser();
}

void LockScreen::ShowParentAccessDialog() {
  contents_view_->ShowParentAccessDialog();
}

void LockScreen::OnLockScreenNoteStateChanged(mojom::TrayActionState state) {
  Shell::Get()
      ->login_screen_controller()
      ->data_dispatcher()
      ->SetLockScreenNoteState(state);
}

void LockScreen::OnSessionStateChanged(session_manager::SessionState state) {
  if (type_ == ScreenType::kLogin &&
      state == session_manager::SessionState::ACTIVE) {
    Destroy();
  }
}

void LockScreen::OnLockStateChanged(bool locked) {
  if (type_ != ScreenType::kLock)
    return;

  if (!locked)
    Destroy();
}

void LockScreen::OnChromeTerminating() {
  Destroy();
}

// static
void LockScreen::ShowWidgetUponWallpaperReady() {
  // |instance_| may already be destroyed in tests.
  if (!instance_ || instance_->is_shown_)
    return;
  instance_->is_shown_ = true;
  instance_->widget_->Show();

  std::vector<base::OnceClosure> on_shown_callbacks;
  swap(instance_->on_shown_callbacks_, on_shown_callbacks);
  for (auto& callback : on_shown_callbacks)
    std::move(callback).Run();

  Shell::Get()->login_screen_controller()->NotifyLoginScreenShown();
}

}  // namespace ash


text:
@interface NoChat (App)

- (void)userDidFailAuthentication;

@end


text:
<?php

/**#@+ @ignore */
require_once("ISO14496/Box/Full.php");
/**#@-*/

/**
 * The <i>Track Header Box</i> specifies the characteristics of a single track.
 * Exactly one Track Header Box is contained in a track.
 *
 * In the absence of an edit list, the presentation of a track starts at the
 * beginning of the overall presentation. An empty edit is used to offset the
 * start time of a track.
 *
 * @package    php-reader
 * @subpackage ISO 14496
 * @author     Sven Vollbehr <svollbehr@gmail.com>
 * @copyright  Copyright (c) 2008 The PHP Reader Project Workgroup
 * @license    http://code.google.com/p/php-reader/wiki/License New BSD License
 * @version    $Rev: 92 $
 */
final class ISO14496_Box_TKHD extends ISO14496_Box_Full
{
  /** @var integer */
  private $_creationTime;

  /** @var integer */
  private $_modificationTime;

  /** @var integer */
  private $_trackId;

  /** @var integer */
  private $_duration;

  /** @var integer */
  private $_width;

  /** @var integer */
  private $_height;

  /**
   * Indicates that the track is enabled. A disabled track is treated as if it
   * were not present.
   */
  const TRACK_ENABLED = 1;

  /** Indicates that the track is used in the presentation. */
  const TRACK_IN_MOVIE = 2;

  /** Indicates that the track is used when previewing the presentation. */
  const TRACK_IN_PREVIEW = 4;

  /**
   * Constructs the class with given parameters and reads box related data from
   * the ISO Base Media file.
   *
   * @param Reader  $reader The reader object.
   */
  public function __construct($reader, &$options = array())
  {
    parent::__construct($reader, $options);

    if ($this->getVersion() == 1) {
      $this->_creationTime = $this->_reader->readInt64BE();
      $this->_modificationTime = $this->_reader->readInt64BE();
      $this->_trackId = $this->_reader->readUInt32BE();
      $this->_reader->skip(4);
      $this->_duration = $this->_reader->readInt64BE();
    } else {
      $this->_creationTime = $this->_reader->readUInt32BE();
      $this->_modificationTime = $this->_reader->readUInt32BE();
      $this->_trackId = $this->_reader->readUInt32BE();
      $this->_reader->skip(4);
      $this->_duration = $this->_reader->readUInt32BE();
    }
    $this->_reader->skip(52);
    $this->_width =
      ((($tmp = $this->_reader->readUInt32BE()) >> 16) & 0xffff) +
      ($tmp & 0xffff) / 10;
    $this->_height =
      ((($tmp = $this->_reader->readUInt32BE()) >> 16) & 0xffff) +
      ($tmp & 0xffff) / 10;
  }

  /**
   * Returns the creation time of this track in seconds since midnight, Jan. 1,
   * 1904, in UTC time.
   *
   * @return integer
   */
  public function getCreationTime() { return $this->_creationTime; }

  /**
   * Returns the most recent time the track was modified in seconds since
   * midnight, Jan. 1, 1904, in UTC time.
   *
   * @return integer
   */
  public function getModificationTime() { return $this->_modificationTime; }

  /**
   * Returns a number that uniquely identifies this track over the entire
   * life-time of this presentation. Track IDs are never re-used and cannot be
   * zero.
   *
   * @return integer
   */
  public function getTrackId() { return $this->_trackId; }

  /**
   * Returns the duration of this track (in the timescale indicated in the
   * {@link MVHD Movie Header Box}). The value of this field is equal to the sum
   * of the durations of all of the track's edits. If there is no edit list,
   * then the duration is the sum of the sample durations, converted into the
   * timescale in the {@link MVHD Movie Header Box}. If the duration of this
   * track cannot be determined then duration is set to all 32-bit maxint.
   *
   * @return integer
   */
  public function getDuration() { return $this->_duration; }

  /**
   * Returns the track's visual presentation width. This needs not be the same
   * as the pixel width of the images; all images in the sequence are scaled to
   * this width, before any overall transformation of the track represented by
   * the matrix. The pixel width of the images is the default value.
   *
   * @return integer
   */
  public function getWidth() { return $this->_rate; }

  /**
   * Returns the track's visual presentation height. This needs not be the same
   * as the pixel height of the images; all images in the sequence are scaled to
   * this height, before any overall transformation of the track represented by
   * the matrix. The pixel height of the images is the default value.
   *
   * @return integer
   */
  public function getHeight() { return $this->_volume; }
}


text:
/**
 *   @author  Antonin Cezard <anc@ecedi.fr>
 *   @license http://www.opensource.org/licenses/MIT MIT
 *   jQuery Pie-Loader Plugin 0.1
 *
 *   Based on jQuery Boilerplate by Zeno Rocha with the help of Addy Osmani
 *   http://jqueryboilerplate.com
 *
 *   Licensed under the MIT license:
 *
 */
/* global jQuery */
(function($) {

    'use strict';

    // Create the defaults once
    var pluginName = 'svgPie',
        defaults = {
            easing: 'easeOutCubic',
            dimension: 200,
            percentage: 50,
            duration: 2000,
            onStart: function() {},
            onComplete: function() {}
        };

    // The actual plugin constructor
    function Plugin(element, options) {
        this.element = element;
        this.settings = $.extend({}, defaults, options);
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }

    // Custom easing function borrowed from jQuery-UI
    $.extend($.easing, {
        easeOutCubic: function(x, t, b, c, d) {
            return c * ((t = t / d - 1) * t * t + 1) + b;
        }
    });

    // Avoid Plugin.prototype conflicts
    $.extend(Plugin.prototype, {

        // Initialization logic
        init: function() {
            $(this.element).css({
                'width': this.settings.dimension + 'px',
                'height': this.settings.dimension + 'px'
            });
            this.createSvg();
            this.animateNumber();
            this.animateStrokeDasharray();
            $(this.element).addClass('rendered');
        },

        // SVG pie markup rendering
        createSvg: function() {
            var half = this.settings.dimension / 2;
            var quarter = this.settings.dimension / 4;
            var area = Math.PI * 2 * quarter;
            var svg =
                '<svg xmlns:svg="http://www.w3.org/2000/svg"' +
                'xmlns="http://www.w3.org/2000/svg"' +
                '>' +

                '<circle r="' + half +
                '" cx="' + half +
                '" cy="' + half +
                '"/>' +

                '<circle r="' + (quarter + 0.5) + // +0.5 to debug non-webkit based browsers
                '" cx="' + half +
                '" cy="' + half + '"' +
                'style="stroke-width:' + half + 'px;' +
                'stroke-dasharray:' + '0px' + ' ' + area + ';' +
                '"/>' +

                '</svg>' +

                '

';

            $(this.element).prepend(svg);
        },

        // Number animation
        animateNumber: function() {
            var $target = $(this.element).find('.percentage');

            $({
                percentageValue: 0
            }).animate({
                percentageValue: this.settings.percentage
            }, {

                duration: this.settings.duration,

                easing: this.settings.easing,

                start: this.settings.onStart,

                step: function() {
                    // Update the element's text with rounded-up value:
                    $target.text(Math.round(this.percentageValue) + '%');
                },

                complete: this.settings.onComplete
            });
        },

        // Pie animation
        animateStrokeDasharray: function() {
            var debug = this.settings.percentage >= 100 ? 1 : 0; // to debug non webkit browsers
            var area = 2 * Math.PI * ((this.settings.dimension / 4) + 0.4); // +0.4 to debug non webkit browsers
            var strokeEndValue = (this.settings.percentage + debug) * area / 100;
            var $target = $(this.element).find('svg circle:nth-child(2)');

            $({
                strokeValue: 0
            }).animate({
                strokeValue: strokeEndValue
            }, {

                duration: this.settings.duration,

                easing: this.settings.easing,

                step: function() {
                    $target.css('stroke-dasharray', this.strokeValue + 'px' + ' ' + area + 'px');
                }
            });

        }

    });

    // A really lightweight plugin wrapper around the constructor,
    // preventing against multiple instantiations
    $.fn[pluginName] = function(options) {
        return this.each(function() {
            if (!$.data(this, 'plugin_' + pluginName)) {
                $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
            }
        });
    };

})(jQuery);


text:
'use strict';

// MODULES //

var dssum = require( '@stdlib/blas/ext/base/dssum' ).ndarray;
var dsapxsum = require( '@stdlib/blas/ext/base/dsapxsum' ).ndarray;

// MAIN //

/**
* Computes the arithmetic mean of a single-precision floating-point strided array using a two-pass error correction algorithm with extended accumulation and returning an extended precision result.
*
* ## Method
*
* -   This implementation uses a two-pass approach, as suggested by Neely (1966).
*
* ## References
*
* -   Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
* -   Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
*
* @param {PositiveInteger} N - number of indexed elements
* @param {Float32Array} x - input array
* @param {integer} stride - stride length
* @param {NonNegativeInteger} offset - starting index
* @returns {number} arithmetic mean
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
* var N = floor( x.length / 2 );
*
* var v = dsmeanpn( N, x, 2, 1 );
* // returns 1.25
*/
function dsmeanpn( N, x, stride, offset ) {
	var mu;
	var c;

	if ( N <= 0 ) {
		return NaN;
	}
	if ( N === 1 || stride === 0 ) {
		return x[ offset ];
	}
	// Compute an estimate for the mean:
	mu = dssum( N, x, stride, offset ) / N;

	// Compute an error term...
	c = dsapxsum( N, -mu, x, stride, offset ) / N;

	return mu + c;
}

// EXPORTS //

module.exports = dsmeanpn;


text:
package org.apache.ant.debugger;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.Task;

public class DebugUtils {

	public static List searchTask(Class expectedTaskClass, Project project) {
		List result = new ArrayList();
		for (Iterator iterator = project.getTargets().values().iterator(); iterator
				.hasNext();) {
			Target t = (Target) iterator.next();
			for (int i = 0; i < t.getTasks().length; i++) {
				Task task = t.getTasks()[i];
				Class taskClass = ComponentHelper.getComponentHelper(project)
						.getComponentClass(task.getTaskType());
				// will need to see in what cases it could return a null type
				// perhaps failing when the task is using a custom antlib
				// defined task
				if (taskClass != null && taskClass.equals(expectedTaskClass)) {
					result.add(task);
				}
			}
		}
		return result;
	}

}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
    <title>File Index</title>
    <link href="doxygen.css" rel="stylesheet" type="text/css">

Main Page

Data Structures

Files

File List

Globals

dmxprop.h

Go to the documentation of this file.

00001
00027
00028 /*
00029  * Authors:
00030  *   Rickard E. (Rik) Faith <faith@redhat.com>
00031  *
00032  */
00033
00037 #ifndef _DMXPROP_H_
00038 #define _DMXPROP_H_
00039 extern int  dmxPropertyDisplay(DMXScreenInfo *dmxScreen);
00040 extern void dmxPropertyWindow(DMXScreenInfo *dmxScreen);
00041 extern void *dmxPropertyIterate(DMXScreenInfo *start,
00042                                 void *(*f)(DMXScreenInfo *dmxScreen,
00043                                            void *closure),
00044                                 void *closure);
00045 extern int dmxPropertySameDisplay(DMXScreenInfo *dmxScreen, const char *name);
00046 #endif

dmxprop.h

    <address>

        Generated June 29, 2004 for Distributed Multihead X by
        doxygen
        1.3.4.

    </addres>


text:
/**
 * Created by troy on 3/8/15.
 */
eventsApp.directive('dateKeys', function () {
        return {
            restrict: 'A',
            link: function (scope, element, attrs, controller) {
                element.on('keydown', function (event) {
                    if( isNumericKeyCode(event.keyCode)
                    || isForwardSlashKeyCode(event.keyCode)
                    || isNavigationKeyCode(event.keyCode)) {
                        console.log("valid keyCode!");
                        return true;
                    }
                    console.log("invalid Key, try again!");
                    event.stopPropagation();
                    event.preventDefault();
                    return false;
                });
            }
        };

        function isNumericKeyCode(keyCode) {
            return (keyCode >= 48 && keyCode <= 57)
                || (keyCode >= 96 && keyCode <= 105);
        }
        function isForwardSlashKeyCode(keyCode) {
            return keyCode == 191;
        }
        function isNavigationKeyCode(keyCode) {
            switch (keyCode) {
                case 8:  //backspace
                case 35: //end
                case 36: //home
                case 37: //left
                case 38: //up
                case 39: //right
                case 40: //down
                case 45: //ins
                case 46: //del
                    return true;
                default:
                    return false;
            }
        }
    });


text:
cd $(dirname $0)

: ${NETBSDSRCDIR=${PWD}/../..}
: ${LLVMSRCDIR=${NETBSDSRCDIR}/external/bsd/llvm/dist}
: ${ARCH=i386}
: ${JOBS=1}
: ${OBJ_LLVM=${NETBSDSRCDIR}/../obj_llvm.${ARCH}}
: ${OBJ=${NETBSDSRCDIR}/../obj.${ARCH}}
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}

echo ${NETBSDSRCDIR}
echo ${LLVMSRCDIR}
echo ${OBJ_LLVM}
echo ${OBJ}
echo ${CROSS_TOOLS}

# Retrieve all the GPL sources
cd ${NETBSDSRCDIR}
find . -name fetch.sh -exec '{}' \;

# Build LLVM manually
mkdir -p  ${OBJ_LLVM}
cd  ${OBJ_LLVM}

${LLVMSRCDIR}/llvm/configure \
    --enable-targets=x86 \
    --with-c-include-dirs=/usr/include/clang-3.4:/usr/include \
    --disable-timestamps \
    --prefix=/usr \
    --sysconfdir=/etc/llvm \
    --with-clang-srcdir=${LLVMSRCDIR}/clang \
    --host=i586-elf32-minix \
    --with-binutils-include=${NETBSDSRCDIR}/external/gpl3/binutils/dist/include \
    --disable-debug-symbols \
    --enable-assertions \
    --enable-bindings=none \
    llvm_cv_gnu_make_command=make \
    ac_cv_path_CIRCO="echo circo" \
    ac_cv_path_DOT="echo dot" \
    ac_cv_path_DOTTY="echo dotty" \
    ac_cv_path_FDP="echo fdp" \
    ac_cv_path_NEATO="echo neato" \
    ac_cv_path_TWOPI="echo twopi" \
    ac_cv_path_XDOT="echo xdot" \
    --enable-optimized

make -j ${JOBS}

# Copy the gold plugin where the NetBSD build system expects it.
mkdir -p ${NETBSDSRCDIR}/minix/llvm/bin/
cp ${OBJ_LLVM}/./Release+Asserts/lib/libLTO.so   ${NETBSDSRCDIR}/minix/llvm/bin/
cp ${OBJ_LLVM}/./Release+Asserts/lib/LLVMgold.so ${NETBSDSRCDIR}/minix/llvm/bin/

# Copy useful LLVM tools
mkdir -p ${CROSS_TOOLS}
cp ${OBJ_LLVM}/./Release+Asserts/bin/llc    ${CROSS_TOOLS}
cp ${OBJ_LLVM}/./Release+Asserts/bin/opt    ${CROSS_TOOLS}
cp ${OBJ_LLVM}/./Release+Asserts/bin/llvm-* ${CROSS_TOOLS}

# Generate and Install default MINIX passes
cd ${NETBSDSRCDIR}/minix/llvm/passes/WeakAliasModuleOverride
make install

cd ${NETBSDSRCDIR}/minix/llvm/passes/hello
make install


text:
/* $NetBSD: if.h,v 1.1.1.3.4.2 2015/02/05 15:13:12 martin Exp $ */

/*
 * dhcpcd - DHCP client daemon
 * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
 * All rights reserved

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef INTERFACE_H
#define INTERFACE_H

#include <sys/socket.h>

#include <net/if.h>
#include <netinet/in.h>

#include "config.h"
#include "dhcpcd.h"
#include "ipv4.h"
#include "ipv6.h"

/* Some systems have route metrics */
#ifndef HAVE_ROUTE_METRIC
# if defined(__linux__) || defined(SIOCGIFPRIORITY)
#  define HAVE_ROUTE_METRIC 1
# endif
# ifndef HAVE_ROUTE_METRIC
#  define HAVE_ROUTE_METRIC 0
# endif
#endif

#define EUI64_ADDR_LEN			8
#define INFINIBAND_ADDR_LEN		20

/* Linux 2.4 doesn't define this */
#ifndef ARPHRD_IEEE1394
#  define ARPHRD_IEEE1394		24
#endif

/* The BSD's don't define this yet */
#ifndef ARPHRD_INFINIBAND
#  define ARPHRD_INFINIBAND		32
#endif

/* Work out if we have a private address or not
 * 10/8
 * 172.16/12
 * 192.168/16
 */
#ifndef IN_PRIVATE
# define IN_PRIVATE(addr) (((addr & IN_CLASSA_NET) == 0x0a000000) ||	      \
	    ((addr & 0xfff00000)    == 0xac100000) ||			      \
	    ((addr & IN_CLASSB_NET) == 0xc0a80000))
#endif

#define LINKLOCAL_ADDR	0xa9fe0000
#define LINKLOCAL_MASK	IN_CLASSB_NET
#define LINKLOCAL_BRDC	(LINKLOCAL_ADDR | ~LINKLOCAL_MASK)

#ifndef IN_LINKLOCAL
# define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR)
#endif

#define RAW_EOF			1 << 0
#define RAW_PARTIALCSUM		2 << 0

int if_setflag(struct interface *ifp, short flag);
#define if_up(ifp) if_setflag((ifp), (IFF_UP | IFF_RUNNING))
struct if_head *if_discover(struct dhcpcd_ctx *, int, char * const *);
struct interface *if_find(struct dhcpcd_ctx *, const char *);
struct interface *if_findindex(struct dhcpcd_ctx *, unsigned int);
void if_free(struct interface *);
int if_domtu(const char *, short int);
#define if_getmtu(iface) if_domtu(iface, 0)
#define if_setmtu(iface, mtu) if_domtu(iface, mtu)
int if_carrier(struct interface *);

/* The below functions are provided by if-KERNEL.c */
int if_conf(struct interface *);
int if_init(struct interface *);
int if_getssid(struct interface *);
int if_vimaster(const char *);
int if_openlinksocket(void);
int if_managelink(struct dhcpcd_ctx *);

#ifdef INET
extern const char *if_pfname;
int if_openrawsocket(struct interface *, int);
ssize_t if_sendrawpacket(const struct interface *,
    int, const void *, size_t);
ssize_t if_readrawpacket(struct interface *, int, void *, size_t, int *);

int if_address(const struct interface *,
    const struct in_addr *, const struct in_addr *,
    const struct in_addr *, int);
#define if_addaddress(ifp, addr, net, brd)	\
	if_address(ifp, addr, net, brd, 1)
#define if_deladdress(ifp, addr, net)		\
	if_address(ifp, addr, net, NULL, -1)

int if_route(const struct rt *rt, int);
#define if_addroute(rt) if_route(rt, 1)
#define if_chgroute(rt) if_route(rt, 0)
#define if_delroute(rt) if_route(rt, -1)
#endif

#ifdef INET6
int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *, int);
int ip6_use_tempaddr(const char *ifname);
int ip6_temp_preferred_lifetime(const char *ifname);
int ip6_temp_valid_lifetime(const char *ifname);

int if_address6(const struct ipv6_addr *, int);
#define if_addaddress6(a) if_address6(a, 1)
#define if_deladdress6(a) if_address6(a, -1)

int if_addrflags6(const struct in6_addr *, const struct interface *);
int if_getlifetime6(struct ipv6_addr *);

int if_route6(const struct rt6 *rt, int);
#define if_addroute6(rt) if_route6(rt, 1)
#define if_chgroute6(rt) if_route6(rt, 0)
#define if_delroute6(rt) if_route6(rt, -1)
#else
#define if_checkipv6(a, b, c) (-1)
#endif

int if_machinearch(char *, size_t);
#endif


text:
'use strict';

import ChildProcess from 'child_process';
import path from 'path';

import Promise from 'bluebird';
import jf from 'jsonfile';
import asar from 'asar';

export default {
	isEmpty(str) {
    return (!str || str.length === 0);
	},
  exec(cmd, args, options) {
    return new Promise((resolve, reject) => {
      ChildProcess.execFile(cmd, args, options, (error, stdout, stderr) => {
        if(error) {
          reject(new Error(`Command\n${cmd} ${args}\n returned non-zero code ${error} with error output ${stderr}`));
        } else {
          resolve(stdout);
        }
      });
    });
  },
  getPackageJson(appDirectory) {
    try {
      return jf.readFileSync(path.resolve(appDirectory, 'resources', 'app', 'package.json'));
    } catch (error) {
      try {
        return JSON.parse(asar.extractFile(path.resolve(appDirectory, 'resources', 'app.asar'), 'package.json'));
      } catch (error) {
        throw new Error('Neither resources/app folder nor resources/app.asar package were found.');
      }
    }
  }
}


text:
/* ----------------------------------------------------------------------
 * Project:      CMSIS DSP Library
 * Title:        arm_abs_q15.c
 * Description:  Q15 vector absolute value
 *
 * $Date:        27. January 2017
 * $Revision:    V.1.5.1
 *
 * Target Processor: Cortex-M cores
 * -------------------------------------------------------------------- */
/*
 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "arm_math.h"

/**
 * @ingroup groupMath
 */

/**
 * @addtogroup BasicAbs
 * @{
 */

/**
 * @brief Q15 vector absolute value.
 * @param[in]       *pSrc points to the input buffer
 * @param[out]      *pDst points to the output buffer
 * @param[in]       blockSize number of samples in each vector
 * @return none.
 *
 * <b>Scaling and Overflow Behavior:</b>
 * \par
 * The function uses saturating arithmetic.
 * The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF.
 */

void arm_abs_q15(
  q15_t * pSrc,
  q15_t * pDst,
  uint32_t blockSize)
{
  uint32_t blkCnt;                               /* loop counter */

#if defined (ARM_MATH_DSP)
  __SIMD32_TYPE *simd;

/* Run the below code for Cortex-M4 and Cortex-M3 */

  q15_t in1;                                     /* Input value1 */
  q15_t in2;                                     /* Input value2 */

  /*loop Unrolling */
  blkCnt = blockSize >> 2U;

  /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
   ** a second loop below computes the remaining 1 to 3 samples. */
  simd = __SIMD32_CONST(pDst);
  while (blkCnt > 0U)
  {
    /* C = |A| */
    /* Read two inputs */
    in1 = *pSrc++;
    in2 = *pSrc++;

    /* Store the Absolute result in the destination buffer by packing the two values, in a single cycle */
#ifndef  ARM_MATH_BIG_ENDIAN
    *simd++ =
      __PKHBT(((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)),
              ((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)), 16);

#else

    *simd++ =
      __PKHBT(((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)),
              ((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)), 16);

#endif /* #ifndef  ARM_MATH_BIG_ENDIAN    */

    in1 = *pSrc++;
    in2 = *pSrc++;

#ifndef  ARM_MATH_BIG_ENDIAN

    *simd++ =
      __PKHBT(((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)),
              ((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)), 16);

#else

    *simd++ =
      __PKHBT(((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)),
              ((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)), 16);

#endif /* #ifndef  ARM_MATH_BIG_ENDIAN    */

    /* Decrement the loop counter */
    blkCnt--;
  }
  pDst = (q15_t *)simd;

  /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
   ** No loop unrolling is used. */
  blkCnt = blockSize % 0x4U;

  while (blkCnt > 0U)
  {
    /* C = |A| */
    /* Read the input */
    in1 = *pSrc++;

    /* Calculate absolute value of input and then store the result in the destination buffer. */
    *pDst++ = (in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1);

    /* Decrement the loop counter */
    blkCnt--;
  }

#else

  /* Run the below code for Cortex-M0 */

  q15_t in;                                      /* Temporary input variable */

  /* Initialize blkCnt with number of samples */
  blkCnt = blockSize;

  while (blkCnt > 0U)
  {
    /* C = |A| */
    /* Read the input */
    in = *pSrc++;

    /* Calculate absolute value of input and then store the result in the destination buffer. */
    *pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in);

    /* Decrement the loop counter */
    blkCnt--;
  }

#endif /* #if defined (ARM_MATH_DSP) */

}

/**
 * @} end of BasicAbs group
 */


text:
package org.arbeitspferde.groningen.common;

import com.google.common.util.concurrent.AbstractExecutionThreadService;

import java.util.logging.Logger;

/**
 * Enables groningen to run indefinitely as a service.
 */
public class GroningenService extends AbstractExecutionThreadService {

  private static final Logger log = Logger.getLogger(GroningenService.class.getCanonicalName());

  @Override
  protected void run() throws Exception {
    log.info("Running Groningen Service");
    synchronized(this) {
      while (isRunning()) {
        wait();
      }
    }
  }

}