text:
from keystoneauth1 import session as keystone
import mock

from sahara import exceptions as ex
from sahara.service import sessions
from sahara.tests.unit import base

class TestSessionCache(base.SaharaTestCase):

    def test_get_session(self):
        sc = sessions.SessionCache()
        session = sc.get_session()
        self.assertIsInstance(session, keystone.Session)

        self.assertRaises(ex.SaharaException,
                          sc.get_session,
                          session_type='bad service')

    @mock.patch('keystoneauth1.session.Session')
    def test_get_keystone_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='keystone')
        self.override_config('api_insecure', False, group='keystone')
        sc.get_session(sessions.SESSION_TYPE_KEYSTONE)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='keystone')
        self.override_config('api_insecure', True, group='keystone')
        sc.get_session(sessions.SESSION_TYPE_KEYSTONE)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_KEYSTONE)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_get_nova_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='nova')
        self.override_config('api_insecure', False, group='nova')
        sc.get_session(sessions.SESSION_TYPE_NOVA)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='nova')
        self.override_config('api_insecure', True, group='nova')
        sc.get_session(sessions.SESSION_TYPE_NOVA)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_NOVA)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_get_cinder_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='cinder')
        self.override_config('api_insecure', False, group='cinder')
        sc.get_session(sessions.SESSION_TYPE_CINDER)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='cinder')
        self.override_config('api_insecure', True, group='cinder')
        sc.get_session(sessions.SESSION_TYPE_CINDER)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_CINDER)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_get_neutron_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='neutron')
        self.override_config('api_insecure', False, group='neutron')
        sc.get_session(sessions.SESSION_TYPE_NEUTRON)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='neutron')
        self.override_config('api_insecure', True, group='neutron')
        sc.get_session(sessions.SESSION_TYPE_NEUTRON)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_NEUTRON)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_get_glance_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='glance')
        self.override_config('api_insecure', False, group='glance')
        sc.get_session(sessions.SESSION_TYPE_GLANCE)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='glance')
        self.override_config('api_insecure', True, group='glance')
        sc.get_session(sessions.SESSION_TYPE_GLANCE)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_GLANCE)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_get_heat_session(self, keystone_session):
        sc = sessions.SessionCache()
        self.override_config('ca_file', '/some/cacert', group='heat')
        self.override_config('api_insecure', False, group='heat')
        sc.get_session(sessions.SESSION_TYPE_HEAT)
        keystone_session.assert_called_once_with(verify='/some/cacert')

        sc = sessions.SessionCache()
        keystone_session.reset_mock()
        self.override_config('ca_file', None, group='heat')
        self.override_config('api_insecure', True, group='heat')
        sc.get_session(sessions.SESSION_TYPE_HEAT)
        keystone_session.assert_called_once_with(verify=False)

        keystone_session.reset_mock()
        sc.get_session(sessions.SESSION_TYPE_HEAT)
        self.assertFalse(keystone_session.called)

    @mock.patch('keystoneauth1.session.Session')
    def test_insecure_session(self, session):
        sc = sessions.SessionCache()
        sc.get_session(sessions.SESSION_TYPE_INSECURE)
        session.assert_called_once_with(verify=False)


text:
<!doctype html>

<title>CodeMirror: VB.NET mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">

<link rel="stylesheet" href="../../lib/codemirror.css">
<link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">

CodeMirror

Home

Manual

Code

Language modes

VB.NET

VB.NET mode

        <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution"></textarea>

MIME type defined: text/x-vb.

redpajama_set_name: RedPajamaGithub


text:
/*	$OpenBSD: autoconf.h,v 1.4 1997/04/16 11:56:33 downsj Exp $	*/
/*	$NetBSD: autoconf.h,v 1.4 1997/04/01 03:03:56 scottr Exp $	*/

/*-
 * Copyright (c) 1996 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Jason R. Thorpe.
 *
 * 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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the NetBSD
 *        Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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.
 */

#ifdef _KERNEL
extern	int conscode;			/* select code of console device */
extern	int consinit_active;		/* hint for drivers */
extern	caddr_t conaddr;		/* KVA of console device */
extern	int convasize;			/* size of mapping at conaddr */
extern	int conforced;			/* console has been forced */

void	configure __P((void));
void	hp300_cninit __P((void));
void	console_scan __P((int (*)(int, caddr_t, void *), void *));
caddr_t	iomap __P((caddr_t, int));
void	iounmap __P((caddr_t, int));

struct device;
void	device_register __P((struct device *, void *));
#endif /* _KERNEL */


text:
package jp.ac.nagoya_u.dsmoq.sdk.request.json

private[request] case class GetDatasetsJson(
  query: Option[String] = None,
  owners: List[String] = List.empty,
  groups: List[String] = List.empty,
  attributes: List[Attribute] = List.empty,
  limit: Option[Int] = Some(20),
  offset: Option[Int] = Some(0)
) extends Jsonable

private[request] case class Attribute(id: String, value: String)


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:orientation="vertical">

    <ImageView
        android:id="@+id/tabImage4"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:background="#00FFFFFF"
        android:src="@drawable/tab_four_selector"/>

    <TextView
        android:id="@+id/tabText4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:text="SMS"
        android:textColor="@drawable/tab_four_text_selector"
        android:textSize="12sp"
        />

</LinearLayout>


text:
package com.rms.db.mapper;

import com.rms.db.model.Project;
import java.util.List;

public interface ProjectMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int insert(Project record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    Project selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    List<Project> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table project
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(Project record);
}


text:
/*******************************************************************************
**
** Description   : this file is for the GFI print buffer
**                 some times, application have many output to be done, e.g.
**                 loop the whole list, and need print then all, but is hard
**                 to print them to console or UI one time, which need long
**                 time and can not lock those data for that long
**                 so here just print those information to a temp buffer
**                 (output to memory is faster), and then output to console
**                 or UI slow.
**
**                 this node is like the RAM disk, which is linked by many small
**                 block, and it is dynamic increased, till reach the maximum
**                 size, which is defined when create
**
** Reference(s)  : TLD document (e.g. )
**
*****************************************************************************/

#ifndef GFI_PRINT_BUFFER_H
#define GFI_PRINT_BUFFER_H

/*****************************************************************************
**
**  1. HEADER (INCLUDE) SECTION
**
*****************************************************************************/

/*****************************************************************************
**
**  2. MACROS           (internal or external according to .h usage)
**
*****************************************************************************/

/* for length for prefix, including
 *     cc,ss,time_stamp                     ==> total 31 bytes
 *     e.g.    01,10,FEB 02 04 00:45:05:607083
 *     ,(after time) "" (for log) \n (last) ==> total  4 bytes
 *                                           so total 35 bytes
 *     add level  8(e.g. CRITICAL) + 1 (,)
 */
#define GFI_LOG_PREFIX_FORMAT_LEN   (35+9)

#define GFI_PRINT_BUF_NAME_LEN      12

/* what's the maximum length for calling gfi_print_buf_add_format_short
 * in this case, will not allocate buffer, but use the local variable
 */
#define GFI_PRINT_BUF_SHORT_LEN     256

/* each print node block size, the size include management header size
 * NOTE: !!!!!!!!!   GFI_PRINT_BUF_NODE_SIZE inpact by the following
 *       a) maximum print buffer length supported,
 *          2K is also used in uiPrint/print/sysprintf
 *       b) each time inter-board sync (used by GFI Log) packet size
 *       c) each log will ONLY in one print buffer node, space impact
 *       ==> so BE CAREFULL if you want to change the size
 */
#define GFI_PRINT_BUF_NODE_SIZE     (2048)  /* each node is 2K, BE CAREFUL when change */
#define GFI_PRINT_BUF_ALLOC_COUNT   (128)   /* each time allcoate 50 node */
#define GFI_PRINT_BUF_REAP_THRESH   (2)     /* when there are 2, reap one */

/* default total size for the print buffer, it can be changed specific
 * when calling the create function
 */
#define GFI_PRINT_BUF_DEFAULT_SIZE  (1024*1024)  /* default is 1 M */

/* define different flag for different applications, each flag in one bit
 * NOTE: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *       DO NOT change the value, it will impact the GFI Log flag
 *       need change them together if REALLY need
 *
 * GFI_PRITN_BUF_FLAG_OVERWRITE: will overwrite the oldest when maximum size is reached
 * GFI_PRITN_BUF_FLAG_OVERSTOP : will stop write when maximum size is reached
 * GFI_PRINT_BUF_FLAG_ALIGNED  : for gfi print, there are two type exist:
 *      1, aligned, means each log/print only exist in one node, used for non-scm
 *         it is easy for sync to ACT-SCM, because sync is node based
 *      2, non-aligned, one log/print may exist in multiple node, used in SCM, memory save
 */
#define GFI_PRITN_BUF_FLAG_OVERWRITE    (0x0001)
#define GFI_PRITN_BUF_FLAG_OVERSTOP     (0x0002)
#define GFI_PRINT_BUF_FLAG_ALIGNED      (0x0004)

#define GFI_PRINT_BUF_DEFAULT_FLAG      (GFI_PRITN_BUF_FLAG_OVERWRITE)

/*
CF added @2012-12-5
    put a long string(more than 2K Bytes) to the gfi-print-buffer
*/
#define GFI_PRINT_BUF_STR_SEG_LEN       (GFI_PRINT_BUF_NODE_SIZE-32)
#define GFI_PRINTF_BUF_PRT_LONG_STRING(printBuffer, str, len)                       \
do{                                                                                \
    int ls = len;                                                                   \
    const char *ss= (str);                                                          \
    int seg_len = 0;                                                                \
    while(ls > 0)                                                                   \
    {                                                                               \
        seg_len = ls > GFI_PRINT_BUF_STR_SEG_LEN ? GFI_PRINT_BUF_STR_SEG_LEN : ls;  \
        gfi_print_buf_add_string(printBuffer,ss,seg_len);                           \
        ss += GFI_PRINT_BUF_STR_SEG_LEN;                                            \
        ls -= seg_len;                                                              \
                                                                                \
    }                                                                               \
}while(0);
/*****************************************************************************
**
**  3. DATA STRUCTURE DEFINITIONS
**
*****************************************************************************/

/****************************************************************************
 * the following is the data structure for the GFI print buffer
 * each print buffer is a list of node, with each of 2K buffer
 * the total buffer size can be set by application
 *
 * each print will only located in ONE print buffer node, which make it easy
 * when sync to ACT/STB SCM, or the log message will be mixed each other

        create_list (all GFI print buffer list together for beffer management)
             |
             V
          --------(node) --------        --------       --------
prt-buf 1 | head |---->  | node | ---->  | node |---->  | node | --> null
          --------       --------        --------       --------
             |(next)
             V
          --------       --------        --------
prt-buf 2 | head |---->  | node | ---->  | node |----> null
          --------       --------        --------
             |
             V
          --------       --------        --------       --------     --------
prt-buf 3 | head |---->  | node | ---->  | node |---->  | node | --> | node | --> null
          --------       --------        --------       --------     --------
             |
             V
          ......
             |
             V
          --------       --------
prt-buf n | head |---->  | node | --> null
          --------       --------
             |
             V
            null

*******************************************************************************/

/* T_gfi_print_node_idx is used for iterator, when do iterator,
 * a) the whole print buffer maybe cleared
 * b) current reading node maybe delete because of overwritten
 *
 * we can not check those via address in pointer, because
 * the buffer maybe freed and we can not check the content.
 * so we MUST have some check whether iterator's current node is still
 * valid or not this idx is used to identify
 *
 * T_gfi_print_node_idx is created when adding to GFI print buffer,
 * and it is unnique for whole lifetime of gfi print buffer, 64bit
 * it is not global unique, because don't want to introduce another
 * lock for this node index update.
 *
 * because GFI print buffer work in a list,
 *       insert to last (largest), and remove from header (minimal)
 * when do iterator, we can easily check whether current iterator is in
 * gfi print buffer list or not by compare the index in iterator.
 *
 * iterator.idx < header.idx
 *        the iterator's node is discard, so reinit
 * header.idx <= iterator.idx <= last.idx
 *        the iterator's node is valid
 * iterator.idx > last.idex
 *        something error, not possible
 *
 */

/* invalid < minimal, so when do iterator, it is easily detected by
 * read_line or read_node, and will update it easily
 */
#define GFI_PRINT_NODE_IDX_INVALID      0
#define GFI_PRINT_NODE_IDX_MINIMAL      1

#define GFI_PRINT_BUFF_MAX_SIZE         (1024*1024)

/* for each print buffer */
typedef struct _T_gfi_print_buffer
{
    uint32 write_offset;
    char buffer [GFI_PRINT_BUFF_MAX_SIZE];
} T_gfi_print_buffer;

typedef T_gfi_print_buffer* T_gfi_print_buffer_id;

#define T_GFI_PRINT_BUFF_SIZE   sizeof(T_gfi_print_buffer)

/*******************************************************************************
**
**  4. FUNCTION PROTOTYPES
**
*******************************************************************************/

/*****************************************************************************
**
**  5. EXTERNAL FUNCTION DEFINITIONS
**
*****************************************************************************/

/* init the print buffer module */
void gfi_print_buf_init(int phase);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_creat(char*  buf_name,  uint32 module_id,
 *                                  uint32 buf_flags, uint32 max_buf_size)
 *
 * Description: this will create the gfi print buffer, all the gfi print buffer
 *              MUST firstly created before usage.
 *
 * Parameter:
 *              buf_name    : slab name, must be static, no stack local address
 *              module_id   : which module the slab belong to, nomall creator
 *              buf_flags   : which feature the slab need to support,
 *                            use GFI_PRINT_BUF_DEFAULT_FLAG
 *              max_buf_size: the maximum of the total print buffer size
 *                            actual size is dynamic increased
 *
 * Return:      created pointer, NULL for failure
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
T_gfi_print_buffer_id gfi_print_buf_creat(char*  buf_name,  uint32 module_id,
                                          uint32 buf_flags, uint32 max_buf_size);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_destroy(T_gfi_print_buffer_id print_buffer_id)
 *
 * Description: this will destroy the print buffer, and release related memory
 *
 * Parameter:
 *              T_gfi_print_buffer_id: the print buffer address
 *
 * Return:
 *         RC_OK                         : successful
 *         RC_GFI_PRINT_BUF_STILL_ENABLED: shoud be disabled before destroy
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
T_global_rc gfi_print_buf_destroy(T_gfi_print_buffer_id print_buffer_id);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_set_enable(T_gfi_print_buffer_id print_buffer_id,
 *                                       uint32 enable_flag)
 *              gfi_print_buf_get_enable(T_gfi_print_buffer_id print_buffer_id)
 *
 * Description: these two functions enable/disable the print buffer, the next
 *              is get the print flag
 *
 *              when print buffer create, it is set to "enable"
 *               "enable" : can write information to print buffer
 *               "disable": can show result and destroy
 *
 * Parameter:
 *              T_gfi_print_buffer_id: the print buffer address
 *              enable_flag          : 1 -- means enable
 *                                     0 -- means disable
 *
 * Return:  NA
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
T_global_rc gfi_print_buf_set_enable(T_gfi_print_buffer_id print_buffer_id, uint32 enable_flag);
uint32      gfi_print_buf_get_enable(T_gfi_print_buffer_id print_buffer_id);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_node_alloc()
 *              gfi_print_buf_node_free(void *tmp_buffer)
 *
 * Description: this is print buffer management supported, application can also
 *              used this interface to allocate buffer used for temp print buffer
 *
 * Parameter:
 *              tmp_buffer  : buffer to be freed
 *
 * Return:
 *      gfi_print_buf_node_alloc: return pointer of buffercreated pointer,
 *                                NULL for failure
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
void*  gfi_print_buf_node_alloc();
void   gfi_print_buf_node_free(void *tmp_buffer);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_add_format(T_gfi_print_buffer_id print_buffer_id,
                                         const char* fmt, ...)
 *
 * Description: this function use the "printf" function like format, write to
 *              print buffer
 *
 * Parameter:
 *              T_gfi_print_buffer_id: the print buffer address
 *              fmt                  : the format is same as standard "printf"
 *
 * Return:
 *              the length added to print buffer (not include terminal '\0')
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
int gfi_print_buf_add_format(T_gfi_print_buffer_id print_buffer_id, const char* fmt, ...);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_add_string(T_gfi_print_buffer_id print_buffer_id,
 *                                       const char* p_string, uint32 str_len)
 *
 * Description: this function write a buffer to print buffer
 *
 * Parameter:
 *              print_buffer: the print buffer address
 *              p_string    : a const string
 *              str_len     : the length of string, *NOT* include terminal '\0'
 *
 * Return:
 *              the length added to print buffer (not include terminal '\0')
 *
 * Function History:
 * 2010/7/27    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
int gfi_print_buf_add_string(T_gfi_print_buffer_id print_buffer_id, const char* p_string, uint32 str_len);

/*****************************************************************************
**  the following interface is about GFI print buffer iterator
*****************************************************************************/

typedef struct {
    T_gfi_print_buffer_id  print_buffer;    /* GFI Print buffer ID */
    uint32                 cur_read_off;    /* the read offset of current print node */
} T_gfi_print_buffer_iterator;

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_it_init(T_gfi_print_buffer_id        print_buffer,
 *                                    T_gfi_print_buffer_iterator* node_it)
 *
 * Description: init the iterator with print buffer, it MUST do this before
 *              any iterator actions
 *
 *
 * Parameter:
 *              print_buffer: the print buffer address
 *              node_it     : address for the node interator
 *
 * Return:  NA
 *
 * Function History:
 * 2012/Feb/3    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
void   gfi_print_buf_it_init(T_gfi_print_buffer_id print_buffer_id,
                             T_gfi_print_buffer_iterator* it);

/*----------------------------------------------------------------------------
 * Function:    gfi_print_buf_it_init(T_gfi_print_buffer_iterator* node_it,
 *                                    char* buffer, uint32 max_buf_size)
 *
 * Description: read one line from the print buffer,
 *              in case the iterator is not valid, auto move to start position
 *              in case of not_aligned buffer, it will read string cross the
 *              print node
 *
 * Parameter:
 *              node_it     : node iterator, it MUST be init firstly before read
 *              buffer      : address used for store the result
 *              max_buf_size: maximum length of buffer, this function will
 *                            read at most max_buf_size-1, the last byte
 *                            is used to store terminated char '\0'
 *
 * Return:     string length, not including terminator '\0', like strlen
 *
 * Function History:
 * 2012/Feb/3    Created      Sun Wenjian
 *
 *--------------------------------------------------------------------------*/
uint32 gfi_print_buf_it_read_line(T_gfi_print_buffer_iterator* node_it,
                                  char* buffer, uint32 max_buf_size);

int gfi_print_buf_output(T_gfi_print_buffer_id print_buffer, char* outbuffer, uint32 max_len);
#endif /* GFI_PRINT_BUFFER_H */


text:
package com.lonelyplanet.akka.http.extensions

import akka.http.scaladsl.server.Rejection

package object rejections {
  case class BadParameterRejection(errorMessage: String) extends Rejection
}


text:
/* jshint indent: 2 */

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('CrawlerNews', {
    CrawlerNewsID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    Type: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "((1))"
    },
    Title: {
      type: DataTypes.STRING,
      allowNull: false
    },
    Content: {
      type: DataTypes.STRING,
      allowNull: false
    },
    Source: {
      type: DataTypes.STRING,
      allowNull: true
    },
    SiteName: {
      type: DataTypes.STRING,
      allowNull: true
    },
    SourceLink: {
      type: DataTypes.STRING,
      allowNull: true
    },
    State: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    PostDate: {
      type: DataTypes.DATE,
      allowNull: false
    },
    LastUpdate: {
      type: DataTypes.DATE,
      allowNull: false
    },
    WebDate: {
      type: DataTypes.DATE,
      allowNull: true,
      defaultValue: " "
    },
    RealName: {
      type: DataTypes.STRING,
      allowNull: true
    },
    Mobile: {
      type: DataTypes.STRING,
      allowNull: true
    },
    UserID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "((0))"
    },
    IsFirst: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "((0))"
    },
    Remark: {
      type: DataTypes.STRING,
      allowNull: true
    },
    PlateID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "((0))"
    }
  }, {
    tableName: 'CrawlerNews'
  });
};


text:
using namespace std;

int larger(int a, int b) {
    if (a > b) {
        return a;
    } else {
        return b;
    }
}

// Returns the larger of the two values.
int main() {
    int bigger1 = larger(17, 42); // call the function
    int bigger2 = larger(29, -3); // call the function again
    int biggest = larger(bigger1, bigger2);
    cout << "The biggest is " << biggest << "!!" << endl;
    return 0;
}


text:
namespace Diadoc {
namespace Api {
namespace Proto {

namespace {

const ::google::protobuf::Descriptor* CustomPrintFormDetectionRequest_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  CustomPrintFormDetectionRequest_reflection_ = NULL;
const ::google::protobuf::Descriptor* CustomPrintFormDetectionResult_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  CustomPrintFormDetectionResult_reflection_ = NULL;
const ::google::protobuf::Descriptor* CustomPrintFormDetectionItemResult_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
  CustomPrintFormDetectionItemResult_reflection_ = NULL;

}  // namespace

void protobuf_AssignDesc_CustomPrintFormDetection_2eproto() {
  protobuf_AddDesc_CustomPrintFormDetection_2eproto();
  const ::google::protobuf::FileDescriptor* file =
    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
      "CustomPrintFormDetection.proto");
  GOOGLE_CHECK(file != NULL);
  CustomPrintFormDetectionRequest_descriptor_ = file->message_type(0);
  static const int CustomPrintFormDetectionRequest_offsets_[1] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionRequest, documentids_),
  };
  CustomPrintFormDetectionRequest_reflection_ =
    new ::google::protobuf::internal::GeneratedMessageReflection(
      CustomPrintFormDetectionRequest_descriptor_,
      CustomPrintFormDetectionRequest::default_instance_,
      CustomPrintFormDetectionRequest_offsets_,
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionRequest, _has_bits_[0]),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionRequest, _unknown_fields_),
      -1,
      ::google::protobuf::DescriptorPool::generated_pool(),
      ::google::protobuf::MessageFactory::generated_factory(),
      sizeof(CustomPrintFormDetectionRequest));
  CustomPrintFormDetectionResult_descriptor_ = file->message_type(1);
  static const int CustomPrintFormDetectionResult_offsets_[1] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionResult, items_),
  };
  CustomPrintFormDetectionResult_reflection_ =
    new ::google::protobuf::internal::GeneratedMessageReflection(
      CustomPrintFormDetectionResult_descriptor_,
      CustomPrintFormDetectionResult::default_instance_,
      CustomPrintFormDetectionResult_offsets_,
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionResult, _has_bits_[0]),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionResult, _unknown_fields_),
      -1,
      ::google::protobuf::DescriptorPool::generated_pool(),
      ::google::protobuf::MessageFactory::generated_factory(),
      sizeof(CustomPrintFormDetectionResult));
  CustomPrintFormDetectionItemResult_descriptor_ = file->message_type(2);
  static const int CustomPrintFormDetectionItemResult_offsets_[2] = {
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionItemResult, documentid_),
    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionItemResult, hascustomprintform_),
  };
  CustomPrintFormDetectionItemResult_reflection_ =
    new ::google::protobuf::internal::GeneratedMessageReflection(
      CustomPrintFormDetectionItemResult_descriptor_,
      CustomPrintFormDetectionItemResult::default_instance_,
      CustomPrintFormDetectionItemResult_offsets_,
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionItemResult, _has_bits_[0]),
      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CustomPrintFormDetectionItemResult, _unknown_fields_),
      -1,
      ::google::protobuf::DescriptorPool::generated_pool(),
      ::google::protobuf::MessageFactory::generated_factory(),
      sizeof(CustomPrintFormDetectionItemResult));
}

namespace {

GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
inline void protobuf_AssignDescriptorsOnce() {
  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
                 &protobuf_AssignDesc_CustomPrintFormDetection_2eproto);
}

void protobuf_RegisterTypes(const ::std::string&) {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
    CustomPrintFormDetectionRequest_descriptor_, &CustomPrintFormDetectionRequest::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
    CustomPrintFormDetectionResult_descriptor_, &CustomPrintFormDetectionResult::default_instance());
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
    CustomPrintFormDetectionItemResult_descriptor_, &CustomPrintFormDetectionItemResult::default_instance());
}

}  // namespace

void protobuf_ShutdownFile_CustomPrintFormDetection_2eproto() {
  delete CustomPrintFormDetectionRequest::default_instance_;
  delete CustomPrintFormDetectionRequest_reflection_;
  delete CustomPrintFormDetectionResult::default_instance_;
  delete CustomPrintFormDetectionResult_reflection_;
  delete CustomPrintFormDetectionItemResult::default_instance_;
  delete CustomPrintFormDetectionItemResult_reflection_;
}

void protobuf_AddDesc_CustomPrintFormDetection_2eproto() {
  static bool already_here = false;
  if (already_here) return;
  already_here = true;
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  ::Diadoc::Api::Proto::protobuf_AddDesc_DocumentId_2eproto();
  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
    "\n\036CustomPrintFormDetection.proto\022\020Diadoc"
    ".Api.Proto\032\020DocumentId.proto\"T\n\037CustomPr"
    "intFormDetectionRequest\0221\n\013DocumentIds\030\001"
    " \003(\0132\034.Diadoc.Api.Proto.DocumentId\"e\n\036Cu"
    "stomPrintFormDetectionResult\022C\n\005Items\030\001 "
    "\003(\01324.Diadoc.Api.Proto.CustomPrintFormDe"
    "tectionItemResult\"r\n\"CustomPrintFormDete"
    "ctionItemResult\0220\n\nDocumentId\030\001 \002(\0132\034.Di"
    "adoc.Api.Proto.DocumentId\022\032\n\022HasCustomPr"
    "intForm\030\002 \002(\010", 373);
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
    "CustomPrintFormDetection.proto", &protobuf_RegisterTypes);
  CustomPrintFormDetectionRequest::default_instance_ = new CustomPrintFormDetectionRequest();
  CustomPrintFormDetectionResult::default_instance_ = new CustomPrintFormDetectionResult();
  CustomPrintFormDetectionItemResult::default_instance_ = new CustomPrintFormDetectionItemResult();
  CustomPrintFormDetectionRequest::default_instance_->InitAsDefaultInstance();
  CustomPrintFormDetectionResult::default_instance_->InitAsDefaultInstance();
  CustomPrintFormDetectionItemResult::default_instance_->InitAsDefaultInstance();
  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_CustomPrintFormDetection_2eproto);
}

// Force AddDescriptors() to be called at static initialization time.
struct StaticDescriptorInitializer_CustomPrintFormDetection_2eproto {
  StaticDescriptorInitializer_CustomPrintFormDetection_2eproto() {
    protobuf_AddDesc_CustomPrintFormDetection_2eproto();
  }
} static_descriptor_initializer_CustomPrintFormDetection_2eproto_;

// ===================================================================

#ifndef _MSC_VER
const int CustomPrintFormDetectionRequest::kDocumentIdsFieldNumber;
#endif  // !_MSC_VER

CustomPrintFormDetectionRequest::CustomPrintFormDetectionRequest()
  : ::google::protobuf::Message() {
  SharedCtor();
  // @@protoc_insertion_point(constructor:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
}

void CustomPrintFormDetectionRequest::InitAsDefaultInstance() {
}

CustomPrintFormDetectionRequest::CustomPrintFormDetectionRequest(const CustomPrintFormDetectionRequest& from)
  : ::google::protobuf::Message() {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
}

void CustomPrintFormDetectionRequest::SharedCtor() {
  _cached_size_ = 0;
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
}

CustomPrintFormDetectionRequest::~CustomPrintFormDetectionRequest() {
  // @@protoc_insertion_point(destructor:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  SharedDtor();
}

void CustomPrintFormDetectionRequest::SharedDtor() {
  if (this != default_instance_) {
  }
}

void CustomPrintFormDetectionRequest::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CustomPrintFormDetectionRequest::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return CustomPrintFormDetectionRequest_descriptor_;
}

const CustomPrintFormDetectionRequest& CustomPrintFormDetectionRequest::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_CustomPrintFormDetection_2eproto();
  return *default_instance_;
}

CustomPrintFormDetectionRequest* CustomPrintFormDetectionRequest::default_instance_ = NULL;

CustomPrintFormDetectionRequest* CustomPrintFormDetectionRequest::New() const {
  return new CustomPrintFormDetectionRequest;
}

void CustomPrintFormDetectionRequest::Clear() {
  documentids_.Clear();
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
  mutable_unknown_fields()->Clear();
}

bool CustomPrintFormDetectionRequest::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // repeated .Diadoc.Api.Proto.DocumentId DocumentIds = 1;
      case 1: {
        if (tag == 10) {
         parse_DocumentIds:
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
                input, add_documentids()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(10)) goto parse_DocumentIds;
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  return false;
#undef DO_
}

void CustomPrintFormDetectionRequest::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  // repeated .Diadoc.Api.Proto.DocumentId DocumentIds = 1;
  for (int i = 0; i < this->documentids_size(); i++) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, this->documentids(i), output);
  }

  if (!unknown_fields().empty()) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        unknown_fields(), output);
  }
  // @@protoc_insertion_point(serialize_end:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
}

::google::protobuf::uint8* CustomPrintFormDetectionRequest::SerializeWithCachedSizesToArray(
    ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  // repeated .Diadoc.Api.Proto.DocumentId DocumentIds = 1;
  for (int i = 0; i < this->documentids_size(); i++) {
    target = ::google::protobuf::internal::WireFormatLite::
      WriteMessageNoVirtualToArray(
        1, this->documentids(i), target);
  }

  if (!unknown_fields().empty()) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        unknown_fields(), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:Diadoc.Api.Proto.CustomPrintFormDetectionRequest)
  return target;
}

int CustomPrintFormDetectionRequest::ByteSize() const {
  int total_size = 0;

  // repeated .Diadoc.Api.Proto.DocumentId DocumentIds = 1;
  total_size += 1 * this->documentids_size();
  for (int i = 0; i < this->documentids_size(); i++) {
    total_size +=
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        this->documentids(i));
  }

  if (!unknown_fields().empty()) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        unknown_fields());
  }
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void CustomPrintFormDetectionRequest::MergeFrom(const ::google::protobuf::Message& from) {
  GOOGLE_CHECK_NE(&from, this);
  const CustomPrintFormDetectionRequest* source =
    ::google::protobuf::internal::dynamic_cast_if_available<const CustomPrintFormDetectionRequest*>(
      &from);
  if (source == NULL) {
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
    MergeFrom(*source);
  }
}

void CustomPrintFormDetectionRequest::MergeFrom(const CustomPrintFormDetectionRequest& from) {
  GOOGLE_CHECK_NE(&from, this);
  documentids_.MergeFrom(from.documentids_);
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}

void CustomPrintFormDetectionRequest::CopyFrom(const ::google::protobuf::Message& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void CustomPrintFormDetectionRequest::CopyFrom(const CustomPrintFormDetectionRequest& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool CustomPrintFormDetectionRequest::IsInitialized() const {

  if (!::google::protobuf::internal::AllAreInitialized(this->documentids())) return false;
  return true;
}

void CustomPrintFormDetectionRequest::Swap(CustomPrintFormDetectionRequest* other) {
  if (other != this) {
    documentids_.Swap(&other->documentids_);
    std::swap(_has_bits_[0], other->_has_bits_[0]);
    _unknown_fields_.Swap(&other->_unknown_fields_);
    std::swap(_cached_size_, other->_cached_size_);
  }
}

::google::protobuf::Metadata CustomPrintFormDetectionRequest::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = CustomPrintFormDetectionRequest_descriptor_;
  metadata.reflection = CustomPrintFormDetectionRequest_reflection_;
  return metadata;
}

// ===================================================================

#ifndef _MSC_VER
const int CustomPrintFormDetectionResult::kItemsFieldNumber;
#endif  // !_MSC_VER

CustomPrintFormDetectionResult::CustomPrintFormDetectionResult()
  : ::google::protobuf::Message() {
  SharedCtor();
  // @@protoc_insertion_point(constructor:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
}

void CustomPrintFormDetectionResult::InitAsDefaultInstance() {
}

CustomPrintFormDetectionResult::CustomPrintFormDetectionResult(const CustomPrintFormDetectionResult& from)
  : ::google::protobuf::Message() {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
}

void CustomPrintFormDetectionResult::SharedCtor() {
  _cached_size_ = 0;
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
}

CustomPrintFormDetectionResult::~CustomPrintFormDetectionResult() {
  // @@protoc_insertion_point(destructor:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  SharedDtor();
}

void CustomPrintFormDetectionResult::SharedDtor() {
  if (this != default_instance_) {
  }
}

void CustomPrintFormDetectionResult::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CustomPrintFormDetectionResult::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return CustomPrintFormDetectionResult_descriptor_;
}

const CustomPrintFormDetectionResult& CustomPrintFormDetectionResult::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_CustomPrintFormDetection_2eproto();
  return *default_instance_;
}

CustomPrintFormDetectionResult* CustomPrintFormDetectionResult::default_instance_ = NULL;

CustomPrintFormDetectionResult* CustomPrintFormDetectionResult::New() const {
  return new CustomPrintFormDetectionResult;
}

void CustomPrintFormDetectionResult::Clear() {
  items_.Clear();
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
  mutable_unknown_fields()->Clear();
}

bool CustomPrintFormDetectionResult::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // repeated .Diadoc.Api.Proto.CustomPrintFormDetectionItemResult Items = 1;
      case 1: {
        if (tag == 10) {
         parse_Items:
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
                input, add_items()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(10)) goto parse_Items;
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  return false;
#undef DO_
}

void CustomPrintFormDetectionResult::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  // repeated .Diadoc.Api.Proto.CustomPrintFormDetectionItemResult Items = 1;
  for (int i = 0; i < this->items_size(); i++) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, this->items(i), output);
  }

  if (!unknown_fields().empty()) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        unknown_fields(), output);
  }
  // @@protoc_insertion_point(serialize_end:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
}

::google::protobuf::uint8* CustomPrintFormDetectionResult::SerializeWithCachedSizesToArray(
    ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  // repeated .Diadoc.Api.Proto.CustomPrintFormDetectionItemResult Items = 1;
  for (int i = 0; i < this->items_size(); i++) {
    target = ::google::protobuf::internal::WireFormatLite::
      WriteMessageNoVirtualToArray(
        1, this->items(i), target);
  }

  if (!unknown_fields().empty()) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        unknown_fields(), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:Diadoc.Api.Proto.CustomPrintFormDetectionResult)
  return target;
}

int CustomPrintFormDetectionResult::ByteSize() const {
  int total_size = 0;

  // repeated .Diadoc.Api.Proto.CustomPrintFormDetectionItemResult Items = 1;
  total_size += 1 * this->items_size();
  for (int i = 0; i < this->items_size(); i++) {
    total_size +=
      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
        this->items(i));
  }

  if (!unknown_fields().empty()) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        unknown_fields());
  }
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void CustomPrintFormDetectionResult::MergeFrom(const ::google::protobuf::Message& from) {
  GOOGLE_CHECK_NE(&from, this);
  const CustomPrintFormDetectionResult* source =
    ::google::protobuf::internal::dynamic_cast_if_available<const CustomPrintFormDetectionResult*>(
      &from);
  if (source == NULL) {
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
    MergeFrom(*source);
  }
}

void CustomPrintFormDetectionResult::MergeFrom(const CustomPrintFormDetectionResult& from) {
  GOOGLE_CHECK_NE(&from, this);
  items_.MergeFrom(from.items_);
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}

void CustomPrintFormDetectionResult::CopyFrom(const ::google::protobuf::Message& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void CustomPrintFormDetectionResult::CopyFrom(const CustomPrintFormDetectionResult& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool CustomPrintFormDetectionResult::IsInitialized() const {

  if (!::google::protobuf::internal::AllAreInitialized(this->items())) return false;
  return true;
}

void CustomPrintFormDetectionResult::Swap(CustomPrintFormDetectionResult* other) {
  if (other != this) {
    items_.Swap(&other->items_);
    std::swap(_has_bits_[0], other->_has_bits_[0]);
    _unknown_fields_.Swap(&other->_unknown_fields_);
    std::swap(_cached_size_, other->_cached_size_);
  }
}

::google::protobuf::Metadata CustomPrintFormDetectionResult::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = CustomPrintFormDetectionResult_descriptor_;
  metadata.reflection = CustomPrintFormDetectionResult_reflection_;
  return metadata;
}

// ===================================================================

#ifndef _MSC_VER
const int CustomPrintFormDetectionItemResult::kDocumentIdFieldNumber;
const int CustomPrintFormDetectionItemResult::kHasCustomPrintFormFieldNumber;
#endif  // !_MSC_VER

CustomPrintFormDetectionItemResult::CustomPrintFormDetectionItemResult()
  : ::google::protobuf::Message() {
  SharedCtor();
  // @@protoc_insertion_point(constructor:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
}

void CustomPrintFormDetectionItemResult::InitAsDefaultInstance() {
  documentid_ = const_cast< ::Diadoc::Api::Proto::DocumentId*>(&::Diadoc::Api::Proto::DocumentId::default_instance());
}

CustomPrintFormDetectionItemResult::CustomPrintFormDetectionItemResult(const CustomPrintFormDetectionItemResult& from)
  : ::google::protobuf::Message() {
  SharedCtor();
  MergeFrom(from);
  // @@protoc_insertion_point(copy_constructor:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
}

void CustomPrintFormDetectionItemResult::SharedCtor() {
  _cached_size_ = 0;
  documentid_ = NULL;
  hascustomprintform_ = false;
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
}

CustomPrintFormDetectionItemResult::~CustomPrintFormDetectionItemResult() {
  // @@protoc_insertion_point(destructor:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  SharedDtor();
}

void CustomPrintFormDetectionItemResult::SharedDtor() {
  if (this != default_instance_) {
    delete documentid_;
  }
}

void CustomPrintFormDetectionItemResult::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* CustomPrintFormDetectionItemResult::descriptor() {
  protobuf_AssignDescriptorsOnce();
  return CustomPrintFormDetectionItemResult_descriptor_;
}

const CustomPrintFormDetectionItemResult& CustomPrintFormDetectionItemResult::default_instance() {
  if (default_instance_ == NULL) protobuf_AddDesc_CustomPrintFormDetection_2eproto();
  return *default_instance_;
}

CustomPrintFormDetectionItemResult* CustomPrintFormDetectionItemResult::default_instance_ = NULL;

CustomPrintFormDetectionItemResult* CustomPrintFormDetectionItemResult::New() const {
  return new CustomPrintFormDetectionItemResult;
}

void CustomPrintFormDetectionItemResult::Clear() {
  if (_has_bits_[0 / 32] & 3) {
    if (has_documentid()) {
      if (documentid_ != NULL) documentid_->::Diadoc::Api::Proto::DocumentId::Clear();
    }
    hascustomprintform_ = false;
  }
  ::memset(_has_bits_, 0, sizeof(_has_bits_));
  mutable_unknown_fields()->Clear();
}

bool CustomPrintFormDetectionItemResult::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // required .Diadoc.Api.Proto.DocumentId DocumentId = 1;
      case 1: {
        if (tag == 10) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
               input, mutable_documentid()));
        } else {
          goto handle_unusual;
        }
        if (input->ExpectTag(16)) goto parse_HasCustomPrintForm;
        break;
      }

      // required bool HasCustomPrintForm = 2;
      case 2: {
        if (tag == 16) {
         parse_HasCustomPrintForm:
          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
                 input, &hascustomprintform_)));
          set_has_hascustomprintform();
        } else {
          goto handle_unusual;
        }
        if (input->ExpectAtEnd()) goto success;
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0 ||
            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  return false;
#undef DO_
}

void CustomPrintFormDetectionItemResult::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  // required .Diadoc.Api.Proto.DocumentId DocumentId = 1;
  if (has_documentid()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      1, this->documentid(), output);
  }

  // required bool HasCustomPrintForm = 2;
  if (has_hascustomprintform()) {
    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->hascustomprintform(), output);
  }

  if (!unknown_fields().empty()) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        unknown_fields(), output);
  }
  // @@protoc_insertion_point(serialize_end:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
}

::google::protobuf::uint8* CustomPrintFormDetectionItemResult::SerializeWithCachedSizesToArray(
    ::google::protobuf::uint8* target) const {
  // @@protoc_insertion_point(serialize_to_array_start:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  // required .Diadoc.Api.Proto.DocumentId DocumentId = 1;
  if (has_documentid()) {
    target = ::google::protobuf::internal::WireFormatLite::
      WriteMessageNoVirtualToArray(
        1, this->documentid(), target);
  }

  // required bool HasCustomPrintForm = 2;
  if (has_hascustomprintform()) {
    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->hascustomprintform(), target);
  }

  if (!unknown_fields().empty()) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        unknown_fields(), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:Diadoc.Api.Proto.CustomPrintFormDetectionItemResult)
  return target;
}

int CustomPrintFormDetectionItemResult::ByteSize() const {
  int total_size = 0;

  if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    // required .Diadoc.Api.Proto.DocumentId DocumentId = 1;
    if (has_documentid()) {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
          this->documentid());
    }

    // required bool HasCustomPrintForm = 2;
    if (has_hascustomprintform()) {
      total_size += 1 + 1;
    }

  }
  if (!unknown_fields().empty()) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        unknown_fields());
  }
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = total_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void CustomPrintFormDetectionItemResult::MergeFrom(const ::google::protobuf::Message& from) {
  GOOGLE_CHECK_NE(&from, this);
  const CustomPrintFormDetectionItemResult* source =
    ::google::protobuf::internal::dynamic_cast_if_available<const CustomPrintFormDetectionItemResult*>(
      &from);
  if (source == NULL) {
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
    MergeFrom(*source);
  }
}

void CustomPrintFormDetectionItemResult::MergeFrom(const CustomPrintFormDetectionItemResult& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_documentid()) {
      mutable_documentid()->::Diadoc::Api::Proto::DocumentId::MergeFrom(from.documentid());
    }
    if (from.has_hascustomprintform()) {
      set_hascustomprintform(from.hascustomprintform());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}

void CustomPrintFormDetectionItemResult::CopyFrom(const ::google::protobuf::Message& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void CustomPrintFormDetectionItemResult::CopyFrom(const CustomPrintFormDetectionItemResult& from) {
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool CustomPrintFormDetectionItemResult::IsInitialized() const {
  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;

  if (has_documentid()) {
    if (!this->documentid().IsInitialized()) return false;
  }
  return true;
}

void CustomPrintFormDetectionItemResult::Swap(CustomPrintFormDetectionItemResult* other) {
  if (other != this) {
    std::swap(documentid_, other->documentid_);
    std::swap(hascustomprintform_, other->hascustomprintform_);
    std::swap(_has_bits_[0], other->_has_bits_[0]);
    _unknown_fields_.Swap(&other->_unknown_fields_);
    std::swap(_cached_size_, other->_cached_size_);
  }
}

::google::protobuf::Metadata CustomPrintFormDetectionItemResult::GetMetadata() const {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::Metadata metadata;
  metadata.descriptor = CustomPrintFormDetectionItemResult_descriptor_;
  metadata.reflection = CustomPrintFormDetectionItemResult_reflection_;
  return metadata;
}

// @@protoc_insertion_point(namespace_scope)

}  // namespace Proto
}  // namespace Api
}  // namespace Diadoc

// @@protoc_insertion_point(global_scope)


text:
package org.apache.camel.tracing;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;

import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Component;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.NamedNode;
import org.apache.camel.Route;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.StaticService;
import org.apache.camel.spi.CamelEvent;
import org.apache.camel.spi.CamelLogger;
import org.apache.camel.spi.InterceptStrategy;
import org.apache.camel.spi.LogListener;
import org.apache.camel.spi.RoutePolicy;
import org.apache.camel.spi.RoutePolicyFactory;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.support.EndpointHelper;
import org.apache.camel.support.EventNotifierSupport;
import org.apache.camel.support.RoutePolicySupport;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.support.service.ServiceSupport;
import org.apache.camel.tracing.decorators.AbstractInternalSpanDecorator;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class Tracer extends ServiceSupport implements RoutePolicyFactory, StaticService, CamelContextAware {
    protected static final Map<String, SpanDecorator> DECORATORS = new HashMap<>();
    private static final Logger LOG = LoggerFactory.getLogger(Tracer.class);

    static {
        ServiceLoader.load(SpanDecorator.class).forEach(d -> {
            SpanDecorator existing = DECORATORS.get(d.getComponent());
            // Add span decorator if no existing decorator for the component,
            // or if derived from the existing decorator's class, allowing
            // custom decorators to be added if they extend the standard
            // decorators
            if (existing == null || existing.getClass().isInstance(d)) {
                DECORATORS.put(d.getComponent(), d);
            }
        });
    }

    protected boolean encoding;
    private final TracingLogListener logListener = new TracingLogListener();
    private final TracingEventNotifier eventNotifier = new TracingEventNotifier();
    private Set<String> excludePatterns = new HashSet<>(0);
    private InterceptStrategy tracingStrategy;
    private CamelContext camelContext;

    protected abstract void initTracer();

    protected abstract SpanAdapter startSendingEventSpan(String operationName, SpanKind kind, SpanAdapter parent);

    protected abstract SpanAdapter startExchangeBeginSpan(
            Exchange exchange, SpanDecorator sd, String operationName, SpanKind kind, SpanAdapter parent);

    protected abstract void finishSpan(SpanAdapter span);

    protected abstract void inject(SpanAdapter span, InjectAdapter adapter);

    /**
     * Returns the currently used tracing strategy which is responsible for tracking invoked EIP or beans.
     *
     * @return The currently used tracing strategy
     */
    public InterceptStrategy getTracingStrategy() {
        return tracingStrategy;
    }

    /**
     * Specifies the instance responsible for tracking invoked EIP and beans with Tracing.
     *
     * @param tracingStrategy The instance which tracks invoked EIP and beans
     */
    public void setTracingStrategy(InterceptStrategy tracingStrategy) {
        this.tracingStrategy = tracingStrategy;
    }

    public void addDecorator(SpanDecorator decorator) {
        DECORATORS.put(decorator.getComponent(), decorator);
    }

    @Override
    public CamelContext getCamelContext() {
        return camelContext;
    }

    @Override
    public void setCamelContext(CamelContext camelContext) {
        this.camelContext = camelContext;
    }

    public Set<String> getExcludePatterns() {
        return excludePatterns;
    }

    public void setExcludePatterns(Set<String> excludePatterns) {
        this.excludePatterns = excludePatterns;
    }

    public boolean isEncoding() {
        return encoding;
    }

    public void setEncoding(boolean encoding) {
        this.encoding = encoding;
    }

    /**
     * Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern.
     *
     * @param pattern the pattern such as route id, endpoint url
     */
    public void addExcludePattern(String pattern) {
        excludePatterns.add(pattern);
    }

    @Override
    public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, NamedNode route) {
        init(camelContext);
        return new TracingRoutePolicy();

    }

    /**
     * Registers this {@link Tracer} on the {@link CamelContext} if not already registered.
     */
    public void init(CamelContext camelContext) {
        if (!camelContext.hasService(this)) {
            try {
                // start this service eager so we init before Camel is starting up
                camelContext.addService(this, true, true);
            } catch (Exception e) {
                throw RuntimeCamelException.wrapRuntimeCamelException(e);
            }
        }
    }

    @Override
    protected void doInit() throws Exception {
        ObjectHelper.notNull(camelContext, "CamelContext", this);

        camelContext.getManagementStrategy().addEventNotifier(eventNotifier);
        if (!camelContext.getRoutePolicyFactories().contains(this)) {
            camelContext.addRoutePolicyFactory(this);
        }
        camelContext.adapt(ExtendedCamelContext.class).addLogListener(logListener);

        if (tracingStrategy != null) {
            camelContext.adapt(ExtendedCamelContext.class).addInterceptStrategy(tracingStrategy);
        }
        initTracer();
        ServiceHelper.startService(eventNotifier);
    }

    @Override
    protected void doShutdown() throws Exception {
        // stop event notifier
        camelContext.getManagementStrategy().removeEventNotifier(eventNotifier);
        ServiceHelper.stopService(eventNotifier);

        // remove route policy
        camelContext.getRoutePolicyFactories().remove(this);
    }

    protected SpanDecorator getSpanDecorator(Endpoint endpoint) {
        SpanDecorator sd = null;

        String uri = endpoint.getEndpointUri();
        String splitURI[] = StringHelper.splitOnCharacter(uri, ":", 2);
        if (splitURI[1] != null) {
            String scheme = splitURI[0];
            sd = DECORATORS.get(scheme);
        }
        if (sd == null) {
            // okay there was no decorator found via component name (scheme), then try FQN
            if (endpoint instanceof DefaultEndpoint) {
                Component comp = ((DefaultEndpoint) endpoint).getComponent();
                String fqn = comp.getClass().getName();
                // lookup via FQN
                sd = DECORATORS.values().stream().filter(d -> fqn.equals(d.getComponentClassName())).findFirst()
                        .orElse(null);
            }
        }
        if (sd == null) {
            sd = SpanDecorator.DEFAULT;
        }

        return sd;
    }

    private boolean isExcluded(Exchange exchange, Endpoint endpoint) {
        String url = endpoint.getEndpointUri();
        if (url != null && !excludePatterns.isEmpty()) {
            for (String pattern : excludePatterns) {
                if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern)) {
                    return true;
                }
            }
        }
        return false;
    }

    private final class TracingEventNotifier extends EventNotifierSupport {

        @Override
        public void notify(CamelEvent event) throws Exception {
            try {
                if (event instanceof CamelEvent.ExchangeSendingEvent) {
                    CamelEvent.ExchangeSendingEvent ese = (CamelEvent.ExchangeSendingEvent) event;
                    SpanDecorator sd = getSpanDecorator(ese.getEndpoint());
                    if (sd instanceof AbstractInternalSpanDecorator || !sd.newSpan()
                            || isExcluded(ese.getExchange(), ese.getEndpoint())) {
                        return;
                    }
                    SpanAdapter parent = ActiveSpanManager.getSpan(ese.getExchange());
                    SpanAdapter span = startSendingEventSpan(sd.getOperationName(ese.getExchange(), ese.getEndpoint()),
                            sd.getInitiatorSpanKind(), parent);
                    sd.pre(span, ese.getExchange(), ese.getEndpoint());
                    inject(span, sd.getInjectAdapter(ese.getExchange().getIn().getHeaders(), encoding));
                    ActiveSpanManager.activate(ese.getExchange(), span);
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Tracing: start client span={}", span);
                    }
                } else if (event instanceof CamelEvent.ExchangeSentEvent) {
                    CamelEvent.ExchangeSentEvent ese = (CamelEvent.ExchangeSentEvent) event;
                    SpanDecorator sd = getSpanDecorator(ese.getEndpoint());
                    if (sd instanceof AbstractInternalSpanDecorator || !sd.newSpan()
                            || isExcluded(ese.getExchange(), ese.getEndpoint())) {
                        return;
                    }
                    SpanAdapter span = ActiveSpanManager.getSpan(ese.getExchange());
                    if (span != null) {
                        if (LOG.isTraceEnabled()) {
                            LOG.trace("Tracing: start client span={}", span);
                        }
                        sd.post(span, ese.getExchange(), ese.getEndpoint());
                        finishSpan(span);
                        ActiveSpanManager.deactivate(ese.getExchange());
                    } else {
                        LOG.warn("Tracing: could not find managed span for exchange={}", ese.getExchange());
                    }
                }
            } catch (Exception t) {
                // This exception is ignored
                LOG.warn("Tracing: Failed to capture tracing data", t);
            }
        }
    }

    private final class TracingRoutePolicy extends RoutePolicySupport {

        @Override
        public void onExchangeBegin(Route route, Exchange exchange) {
            try {
                if (isExcluded(exchange, route.getEndpoint())) {
                    return;
                }
                SpanDecorator sd = getSpanDecorator(route.getEndpoint());
                SpanAdapter parent = ActiveSpanManager.getSpan(exchange);
                SpanAdapter span;
                span = startExchangeBeginSpan(exchange, sd, sd.getOperationName(exchange, route.getEndpoint()),
                        sd.getReceiverSpanKind(), parent);
                sd.pre(span, exchange, route.getEndpoint());
                ActiveSpanManager.activate(exchange, span);
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Tracing: start server span={}", span);
                }
            } catch (Exception t) {
                // This exception is ignored
                LOG.warn("Tracing: Failed to capture tracing data", t);
            }
        }

        @Override
        public void onExchangeDone(Route route, Exchange exchange) {
            try {
                if (isExcluded(exchange, route.getEndpoint())) {
                    return;
                }
                SpanAdapter span = ActiveSpanManager.getSpan(exchange);
                if (span != null) {
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Tracing: finish server span={}", span);
                    }
                    SpanDecorator sd = getSpanDecorator(route.getEndpoint());
                    sd.post(span, exchange, route.getEndpoint());
                    finishSpan(span);
                    ActiveSpanManager.deactivate(exchange);
                } else {
                    LOG.warn("Tracing: could not find managed span for exchange={}", exchange);
                }
            } catch (Exception t) {
                // This exception is ignored
                LOG.warn("Tracing: Failed to capture tracing data", t);
            }
        }
    }

    private final class TracingLogListener implements LogListener {

        @Override
        public String onLog(Exchange exchange, CamelLogger camelLogger, String message) {
            try {
                SpanAdapter span = ActiveSpanManager.getSpan(exchange);
                if (span != null) {
                    Map<String, String> fields = new HashMap<>();
                    fields.put("message", message);
                    span.log(fields);
                }
            } catch (Exception t) {
                // This exception is ignored
                LOG.warn("Tracing: Failed to capture tracing data", t);
            }
            return message;
        }
    }
}


text:
\chapter{Functional languages}

## Haskell
Haskell is a standardized, general-purpose purely functional programming
language, with non-strict semantics and strong static typing.

```haskell
module Main where

main :: IO ()
main = putStrLn "Hello, World!"
```


text:
require 'rails_helper'

# Required for class_double
require_relative '../../app/services/create_multi_year_chart'

describe MultiYearChartsController do
  describe '#create' do
    context 'when signed in and given a valid saved scenario ID' do
      let(:scenario) { FactoryBot.create(:saved_scenario, end_year: 2050, user: user) }
      let(:user) { FactoryBot.create(:user) }
      let(:myc) { FactoryBot.create(:multi_year_chart, scenarios_count: 1) }

      let!(:service) { class_double('CreateMultiYearChart').as_stubbed_const }

      before do
        login_as user

        allow(service).to receive(:call).and_return(ServiceResult.success(myc))
      end

      it 'redirects to the MYC app' do
        post :create, params: { scenario_id: scenario.id }

        expect(response).to redirect_to(
          %r{^#{Settings.multi_year_charts_url}/#{myc.redirect_slug}}
        )
      end

      it 'calls the CreateMultiYearChart service' do
        post :create, params: { scenario_id: scenario.id }
        expect(service).to have_received(:call).with(scenario, user)
      end
    end

    context 'when signed in and given someone elses saved scenario ID' do
      let(:scenario) { FactoryBot.create(:saved_scenario, end_year: 2050) }

      before { login_as FactoryBot.create(:user) }

      it 'raises a Not Found error' do
        expect { post(:create, params: { scenario_id: scenario.id }) }
          .to raise_error(ActiveRecord::RecordNotFound)
      end
    end

    context 'when signed in and the CreateMultiYearChart service fails' do
      let(:scenario) { FactoryBot.create(:saved_scenario, end_year: 2050, user: user) }
      let(:api_scenario) { FactoryBot.build(:api_scenario) }
      let(:user) { FactoryBot.create(:user) }

      let!(:service) { class_double('CreateMultiYearChart').as_stubbed_const }

      before do
        login_as user

        allow(service).to receive(:call).and_return(ServiceResult.failure(
          "That didn't work."
        ))

        allow(Api::Scenario).to receive(:find)
          .with(scenario.scenario_id).and_return(api_scenario)

        allow(Api::Scenario).to receive(:batch_load).and_return([api_scenario])
      end

      it 'fails the request with a 422 code' do
        post :create, params: { scenario_id: scenario.id }
        expect(response.status).to eq(422)
      end

      it 'renders the index' do
        post :create, params: { scenario_id: scenario.id }
        expect(response).to render_template(:index)
      end

      it 'sets the error message in the flash' do
        post :create, params: { scenario_id: scenario.id }
        expect(flash[:error]).to eq("That didn't work.")
      end

      it 'calls the CreateMultiYearChart service' do
        post :create, params: { scenario_id: scenario.id }
        expect(service).to have_received(:call).with(scenario, user)
      end
    end

    context 'when not signed in signed in' do
      let(:scenario) { FactoryBot.build(:api_scenario, id: 1) }

      it 'redirects to the login page' do
        post :create, params: { scenario_id: scenario.id }
        expect(response).to redirect_to(login_url)
      end
    end
  end

  describe '#destroy' do
    let!(:service) { class_double('DeleteMultiYearChart').as_stubbed_const }

    context 'when the MYC belongs to the logged-in user' do
      let(:myc) { FactoryBot.create(:multi_year_chart) }

      before do
        allow(service).to receive(:call).and_return(ServiceResult.success)
        login_as myc.user
      end

      it 'redirects to the MYC root' do
        delete :destroy, params: { id: myc.id }
        expect(response).to redirect_to(multi_year_charts_url)
      end

      it 'calls the DeleteMultiYearChart service' do
        delete :destroy, params: { id: myc.id }
        expect(service).to have_received(:call).with(myc)
      end
    end

    context 'when the MYC belongs to a different user' do
      let(:myc) { FactoryBot.create(:multi_year_chart) }

      before do
        login_as FactoryBot.create(:user)
      end

      it 'raises RecordNotFound' do
        expect { delete :destroy, params: { id: myc.id } }
          .to raise_error(ActiveRecord::RecordNotFound)
      end
    end

    context 'when not signed in signed in' do
      let(:myc) { FactoryBot.create(:multi_year_chart) }

      it 'redirects to the login page' do
        delete :destroy, params: { id: myc.id }
        expect(response).to redirect_to(login_url)
      end
    end
  end
end


text:
**springboot-essentials**: This module is a basic SpringBoot web application to show how to use Logging, ConfigurationProperties etc.

#### How to run?

To run with default profile:

springboot-essentials> mvn clean package spring-boot:run

To run with prod profile:

springboot-essentials> mvn clean package spring-boot:run -Dspring.profiles.active=prod

To run with test profile:

springboot-essentials> mvn test


text:
/*
 * 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
 *
 * http://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.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.monitoring.v3.model;

/**
 * A Service is a discrete, autonomous, and network-accessible unit, designed to solve an individual
 * concern (Wikipedia (https://en.wikipedia.org/wiki/Service-orientation)). In Cloud Monitoring, a
 * Service acts as the root resource under which operational aspects of the service are accessible.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Cloud Monitoring API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class Service extends com.google.api.client.json.GenericJson {

  /**
   * Type used for App Engine services.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private AppEngine appEngine;

  /**
   * Type used for Cloud Endpoints services.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private CloudEndpoints cloudEndpoints;

  /**
   * Type used for Cloud Run services.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private CloudRun cloudRun;

  /**
   * Type used for Istio services that live in a Kubernetes cluster.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private ClusterIstio clusterIstio;

  /**
   * Custom service type.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private Custom custom;

  /**
   * Name used for UI elements listing this Service.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String displayName;

  /**
   * Type used for GKE Namespaces.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private GkeNamespace gkeNamespace;

  /**
   * Type used for GKE Services (the Kubernetes concept of a service).
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private GkeService gkeService;

  /**
   * Type used for GKE Workloads.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private GkeWorkload gkeWorkload;

  /**
   * Type used for canonical services scoped to an Istio mesh. Metrics for Istio are documented here
   * (https://istio.io/latest/docs/reference/config/metrics/)
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private IstioCanonicalService istioCanonicalService;

  /**
   * Type used for Istio services scoped to an Istio mesh.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private MeshIstio meshIstio;

  /**
   * Resource name for this Service. The format is:
   * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String name;

  /**
   * Configuration for how to query telemetry on a Service.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private Telemetry telemetry;

  /**
   * Labels which have been used to annotate the service. Label keys must start with a letter. Label
   * keys and values may contain lowercase letters, numbers, underscores, and dashes. Label keys and
   * values have a maximum length of 63 characters, and must be less than 128 bytes in size. Up to
   * 64 label entries may be stored. For labels which do not have a semantic value, the empty string
   * may be supplied for the label value.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.util.Map<String, java.lang.String> userLabels;

  /**
   * Type used for App Engine services.
   * @return value or {@code null} for none
   */
  public AppEngine getAppEngine() {
    return appEngine;
  }

  /**
   * Type used for App Engine services.
   * @param appEngine appEngine or {@code null} for none
   */
  public Service setAppEngine(AppEngine appEngine) {
    this.appEngine = appEngine;
    return this;
  }

  /**
   * Type used for Cloud Endpoints services.
   * @return value or {@code null} for none
   */
  public CloudEndpoints getCloudEndpoints() {
    return cloudEndpoints;
  }

  /**
   * Type used for Cloud Endpoints services.
   * @param cloudEndpoints cloudEndpoints or {@code null} for none
   */
  public Service setCloudEndpoints(CloudEndpoints cloudEndpoints) {
    this.cloudEndpoints = cloudEndpoints;
    return this;
  }

  /**
   * Type used for Cloud Run services.
   * @return value or {@code null} for none
   */
  public CloudRun getCloudRun() {
    return cloudRun;
  }

  /**
   * Type used for Cloud Run services.
   * @param cloudRun cloudRun or {@code null} for none
   */
  public Service setCloudRun(CloudRun cloudRun) {
    this.cloudRun = cloudRun;
    return this;
  }

  /**
   * Type used for Istio services that live in a Kubernetes cluster.
   * @return value or {@code null} for none
   */
  public ClusterIstio getClusterIstio() {
    return clusterIstio;
  }

  /**
   * Type used for Istio services that live in a Kubernetes cluster.
   * @param clusterIstio clusterIstio or {@code null} for none
   */
  public Service setClusterIstio(ClusterIstio clusterIstio) {
    this.clusterIstio = clusterIstio;
    return this;
  }

  /**
   * Custom service type.
   * @return value or {@code null} for none
   */
  public Custom getCustom() {
    return custom;
  }

  /**
   * Custom service type.
   * @param custom custom or {@code null} for none
   */
  public Service setCustom(Custom custom) {
    this.custom = custom;
    return this;
  }

  /**
   * Name used for UI elements listing this Service.
   * @return value or {@code null} for none
   */
  public java.lang.String getDisplayName() {
    return displayName;
  }

  /**
   * Name used for UI elements listing this Service.
   * @param displayName displayName or {@code null} for none
   */
  public Service setDisplayName(java.lang.String displayName) {
    this.displayName = displayName;
    return this;
  }

  /**
   * Type used for GKE Namespaces.
   * @return value or {@code null} for none
   */
  public GkeNamespace getGkeNamespace() {
    return gkeNamespace;
  }

  /**
   * Type used for GKE Namespaces.
   * @param gkeNamespace gkeNamespace or {@code null} for none
   */
  public Service setGkeNamespace(GkeNamespace gkeNamespace) {
    this.gkeNamespace = gkeNamespace;
    return this;
  }

  /**
   * Type used for GKE Services (the Kubernetes concept of a service).
   * @return value or {@code null} for none
   */
  public GkeService getGkeService() {
    return gkeService;
  }

  /**
   * Type used for GKE Services (the Kubernetes concept of a service).
   * @param gkeService gkeService or {@code null} for none
   */
  public Service setGkeService(GkeService gkeService) {
    this.gkeService = gkeService;
    return this;
  }

  /**
   * Type used for GKE Workloads.
   * @return value or {@code null} for none
   */
  public GkeWorkload getGkeWorkload() {
    return gkeWorkload;
  }

  /**
   * Type used for GKE Workloads.
   * @param gkeWorkload gkeWorkload or {@code null} for none
   */
  public Service setGkeWorkload(GkeWorkload gkeWorkload) {
    this.gkeWorkload = gkeWorkload;
    return this;
  }

  /**
   * Type used for canonical services scoped to an Istio mesh. Metrics for Istio are documented here
   * (https://istio.io/latest/docs/reference/config/metrics/)
   * @return value or {@code null} for none
   */
  public IstioCanonicalService getIstioCanonicalService() {
    return istioCanonicalService;
  }

  /**
   * Type used for canonical services scoped to an Istio mesh. Metrics for Istio are documented here
   * (https://istio.io/latest/docs/reference/config/metrics/)
   * @param istioCanonicalService istioCanonicalService or {@code null} for none
   */
  public Service setIstioCanonicalService(IstioCanonicalService istioCanonicalService) {
    this.istioCanonicalService = istioCanonicalService;
    return this;
  }

  /**
   * Type used for Istio services scoped to an Istio mesh.
   * @return value or {@code null} for none
   */
  public MeshIstio getMeshIstio() {
    return meshIstio;
  }

  /**
   * Type used for Istio services scoped to an Istio mesh.
   * @param meshIstio meshIstio or {@code null} for none
   */
  public Service setMeshIstio(MeshIstio meshIstio) {
    this.meshIstio = meshIstio;
    return this;
  }

  /**
   * Resource name for this Service. The format is:
   * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
   * @return value or {@code null} for none
   */
  public java.lang.String getName() {
    return name;
  }

  /**
   * Resource name for this Service. The format is:
   * projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
   * @param name name or {@code null} for none
   */
  public Service setName(java.lang.String name) {
    this.name = name;
    return this;
  }

  /**
   * Configuration for how to query telemetry on a Service.
   * @return value or {@code null} for none
   */
  public Telemetry getTelemetry() {
    return telemetry;
  }

  /**
   * Configuration for how to query telemetry on a Service.
   * @param telemetry telemetry or {@code null} for none
   */
  public Service setTelemetry(Telemetry telemetry) {
    this.telemetry = telemetry;
    return this;
  }

  /**
   * Labels which have been used to annotate the service. Label keys must start with a letter. Label
   * keys and values may contain lowercase letters, numbers, underscores, and dashes. Label keys and
   * values have a maximum length of 63 characters, and must be less than 128 bytes in size. Up to
   * 64 label entries may be stored. For labels which do not have a semantic value, the empty string
   * may be supplied for the label value.
   * @return value or {@code null} for none
   */
  public java.util.Map<String, java.lang.String> getUserLabels() {
    return userLabels;
  }

  /**
   * Labels which have been used to annotate the service. Label keys must start with a letter. Label
   * keys and values may contain lowercase letters, numbers, underscores, and dashes. Label keys and
   * values have a maximum length of 63 characters, and must be less than 128 bytes in size. Up to
   * 64 label entries may be stored. For labels which do not have a semantic value, the empty string
   * may be supplied for the label value.
   * @param userLabels userLabels or {@code null} for none
   */
  public Service setUserLabels(java.util.Map<String, java.lang.String> userLabels) {
    this.userLabels = userLabels;
    return this;
  }

  @Override
  public Service set(String fieldName, Object value) {
    return (Service) super.set(fieldName, value);
  }

  @Override
  public Service clone() {
    return (Service) super.clone();
  }

}


text:
package com.tripvi.imagegrid;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;

import org.appcelerator.titanium.TiApplication;
import org.appcelerator.kroll.common.Log;

@Kroll.module(name="Imagegrid", id="com.tripvi.imagegrid")
public class ImagegridModule extends KrollModule
{
	// Standard Debugging variables
	private static final String TAG = "Tripvi.ImageGridModule";

	// You can define constants with @Kroll.constant, for example:
	// @Kroll.constant public static final String EXTERNAL_NAME = value;

	public ImagegridModule()
	{
		super();
	}

	@Kroll.onAppCreate
	public static void onAppCreate(TiApplication app)
	{
		// put module init code that needs to run when the application is created
	}

}


text:
#ifndef _IVR_IMS_INFO_H_
#define _IVR_IMS_INFO_H_

#include "common.h"
#include "ims_struct.h"

class ims_event_receiver;
// ims information
class ims_info_t : public bgcc::Shareable {
public:
    ims_info_t(uint32_t imsno, const std::string& ip, uint32_t port);
    ims_info_t(const ims_info_t& other);
    virtual ~ims_info_t();
public:
    // get current proxy and reqid
    // if proxy had not created, create it
    // if ims has not regist, rigist at ims
    // will update _reqid
    int32_t get_info(imsapi_proxy_pointer& proxy, ims_reqid_t& reqid);

    // re-regist at this ims
    // if reqid != _reqid, just return failed
    int32_t update(ims_reqid_t reqid);

    // get ims number: return _no
    uint32_t get_imsno() const;
protected:
    // if regist at ims
    int32_t _regist_ims();
protected:
    struct imsproxy_opr;
protected:
    // ims number(index)
    uint32_t _no;

    // ims ip, used to listen ims event or get heartbeat
    std::string _ip;

    // ims port, used to listen ims event or get heartbeat
    uint32_t _port;

    // the identity of the service unit @ims, return after registed at ims
    ims_reqid_t _reqid;

    // last call register time
    time_t _lastinit_time;
protected:
    // proxy of this ims
    imsapi_proxy_pointer _proxy;
    // locker of _proxy
    bgcc::Mutex _ctx_mutex;
};

typedef bgcc::SharedPointer<ims_info_t> ims_info;

#endif


text:
namespace Craswell.Automation.DataAccess
{
    /// <summary>
    /// The web repository interface definition.
    /// </summary>
    public interface IWebRepository
    {
        /// <summary>
        /// Gets the repository identifier.
        /// </summary>
        /// <value>The identifier.</value>
        int Id { get; }

        /// <summary>
        /// Gets the name of the repository.
        /// </summary>
        /// <value>The name of the repository.</value>
        string Name { get; }

        /// <summary>
        /// Gets the repository type.
        /// </summary>
        /// <value>The repository type.</value>
        WebRepositoryType Type { get; }
    }
}


text:
import { Pipe, PipeTransform } from '@angular/core';
import * as _ from 'lodash';

@Pipe({
    name: 'FilterByProperty'
})

export class FilterByPropertyPipe implements PipeTransform {
    transform(catalog: any, property:string, term: string): any {
        //return _.filter(catalog, [property, term]);

        return _.filter(catalog, (item) => {
            return item[property].search(term) !== -1;
        });
    }
}