text:
package com.sferadev.danacast.providers;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.sferadev.danacast.R;
import com.sferadev.danacast.activities.MainActivity;
import com.sferadev.danacast.helpers.Constants;
import com.sferadev.danacast.models.EntryModel;
import com.sferadev.danacast.utils.PreferenceUtils;

import org.apache.commons.lang3.text.WordUtils;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;

public class Pordede {
    public static ArrayList<EntryModel> getSearchResults(final Context context, final String query) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect("http://www.pordede.com/search/" +
                            query.replace(" ", "-"))
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements elements = document.select("div.listContainer.listCovers.clearfix").first()
                            .select("div.ddItemContainer.modelContainer");
                    for (Element element : elements) {
                        String title = element.getElementsByClass("title").text();
                        String url = element.select("a.defaultLink.extended").first().attr("abs:href");
                        boolean isShow = element.getElementsByClass("searchType").text().equals("Serie");
                        result.add(new EntryModel(isShow ? Constants.TYPE_SHOW : Constants.TYPE_MOVIE,
                                title, url, null));
                    }
                } catch (IOException | NullPointerException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ArrayList<EntryModel> getPopularShows(final Context context) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect("http://www.pordede.com/series/index/showlist/viewed")
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements elements = document.getElementsByClass("listContainer").first().getElementsByClass("ddItemContainer");
                    for (Element element : elements) {
                        String title = element.getElementsByClass("title").first().text();
                        String showUrl = element.getElementsByClass("extended").first().attr("abs:href");
                        String picUrl = element.getElementsByClass("centeredPicFalse").first().attr("src");
                        result.add(new EntryModel(Constants.TYPE_SHOW, title, showUrl, picUrl));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ArrayList<EntryModel> getPopularMovies(final Context context) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect("http://www.pordede.com/pelis/index/showlist/viewed")
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements elements = document.getElementsByClass("listContainer").first().getElementsByClass("ddItemContainer");
                    for (Element element : elements) {
                        String title = element.getElementsByClass("title").first().text();
                        String showUrl = element.getElementsByClass("extended").first().attr("abs:href");
                        String picUrl = element.getElementsByClass("centeredPicFalse").first().attr("src");
                        result.add(new EntryModel(Constants.TYPE_MOVIE, title, showUrl, picUrl));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ArrayList<EntryModel> getEpisodeList(final Context context, final String url) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect(url)
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements seasons = document.getElementsByClass("episodes");
                    for (Element season : seasons) {
                        Elements episodes = season.select("div.modelContainer.defaultPopup");
                        String seasonName = season.getElementsByClass("checkSeason").first().attr("data-num");
                        for (Element link : episodes) {
                            String title = seasonName + "x" + link.getElementsByClass("title").first().text();
                            String episodeUrl = link.getElementsByClass("title").first().attr("abs:href");
                            result.add(new EntryModel(Constants.TYPE_EPISODE, title, episodeUrl, null));
                        }
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ArrayList<EntryModel> getEpisodeLinks(final Context context, final String url) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect(url)
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements elements = document.select("div.linksContainer.online.tabContent").first()
                            .select("a.a.aporteLink.done");
                    for (Element element : elements) {
                        String title = WordUtils.capitalize(element.getElementsByClass("hostimage").first()
                                .child(0).attr("src").replace("http://www.pordede.com/images/hosts/popup_", "").split("\\.")[0]);
                        String linkUrl = element.attr("abs:href");
                        String language = WordUtils.capitalize(element.getElementsByClass("flags").first()
                                .child(0).classNames().toArray()[1].toString());
                        String quality = element.getElementsByClass("quality").first().text();
                        result.add(new EntryModel(Constants.TYPE_LINK, title +
                                " (" + language + " | " + quality + ")", linkUrl, null));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static ArrayList<EntryModel> getMovieLinks(final Context context, final String url) {
        final ArrayList<EntryModel> result = new ArrayList<>();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    String[] splitUrl = url.split("\\/");
                    Document document = Jsoup.connect("http://www.pordede.com/links/view/slug/" +
                            splitUrl[splitUrl.length - 1] + "/what/peli")
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Elements elements = document.select("div.linksContainer.online.tabContent").first()
                            .select("a.a.aporteLink.done");
                    for (Element element : elements) {
                        String title = WordUtils.capitalize(element.getElementsByClass("hostimage").first()
                                .child(0).attr("src").replace("http://www.pordede.com/images/hosts/popup_", "").split("\\.")[0]);
                        String linkUrl = element.attr("abs:href");
                        String language = WordUtils.capitalize(element.getElementsByClass("flags").first()
                                .child(0).classNames().toArray()[1].toString());
                        String quality = element.getElementsByClass("quality").first().text();
                        result.add(new EntryModel(Constants.TYPE_LINK, title +
                                " (" + language + " | " + quality + ")", linkUrl, null));
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result;
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String getExternalLink(final Context context, final String url) {
        final String[] result = {null};
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Document document = Jsoup.connect(url)
                            .cookies(loginResponse(context).cookies())
                            .referrer("http://www.google.com")
                            .get();
                    Element element = document.select("p.links").first().child(0);
                    result[0] = Jsoup.connect(element.attr("abs:href"))
                            .cookies(loginResponse(context).cookies())
                            .followRedirects(true)
                            .execute().url().toExternalForm();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result[0];
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return null;
        }
    }

    private static Connection.Response loginResponse(Context context) throws IOException {
        return Jsoup.connect("http://www.pordede.com/site/login")
                .data("LoginForm[username]", PreferenceUtils.getPreference(context,
                        PreferenceUtils.PROPERTY_PORDEDE_USER, null))
                .data("LoginForm[password]", PreferenceUtils.getPreference(context,
                        PreferenceUtils.PROPERTY_PORDEDE_PASS, null))
                .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                .method(Connection.Method.POST).timeout(0).execute();
    }

    public static boolean isLoggedInCredentials(Context context) {
        return PreferenceUtils.getPreference(context,
                PreferenceUtils.PROPERTY_PORDEDE_USER, null) != null;
    }

    public static void loginWithCredentials(final Context context) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View view = inflater.inflate(R.layout.dialog_pordede_login, null);
        builder.setView(view)
                .setPositiveButton(R.string.login_signin, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        EditText usernameEditText = (EditText) view.findViewById(R.id.username);
                        String username = usernameEditText.getText().toString().trim();
                        EditText passwordEditText = (EditText) view.findViewById(R.id.password);
                        String password = passwordEditText.getText().toString().trim();
                        if (checkUser(username, password)) {
                            PreferenceUtils.setPreference(context, PreferenceUtils.PROPERTY_PORDEDE_USER,
                                    username);
                            PreferenceUtils.setPreference(context, PreferenceUtils.PROPERTY_PORDEDE_PASS,
                                    password);
                            Toast.makeText(context, context.getString(R.string.login_success), Toast.LENGTH_LONG).show();
                            restartApp(context);
                            dialog.dismiss();
                        } else {
                            Toast.makeText(context, context.getString(R.string.login_failure), Toast.LENGTH_LONG).show();
                        }
                    }
                })
                .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        builder.create().show();
    }

    private static boolean checkUser(final String username, final String password) {
        final boolean[] result = new boolean[1];
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Connection.Response loginResponse = Jsoup.connect("http://www.pordede.com/site/login")
                            .data("LoginForm[username]", username)
                            .data("LoginForm[password]", password)
                            .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                            .method(Connection.Method.POST).timeout(0).execute();

                    Document document = Jsoup.connect("http://www.pordede.com/series/index/showlist/viewed")
                            .cookies(loginResponse.cookies())
                            .referrer("http://www.google.com")
                            .get();
                    document.getElementsByClass("listContainer").first().getElementsByClass("ddItemContainer");
                    result[0] = true;
                } catch (IOException | NullPointerException e) {
                    e.printStackTrace();
                    result[0] = false;
                }
            }
        });
        thread.start();
        try {
            thread.join();
            return result[0];
        } catch (InterruptedException | NullPointerException e) {
            e.printStackTrace();
            return false;
        }

    }

    private static void restartApp(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, MainActivity.class);
        ((Activity) context).finish();
        context.startActivity(intent);
    }
}


text:
[![License Apache2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)

A reference application for Java developers looking to learn more about using [Apache Cassandra][cassandra] and
[DataStax Enterprise][dse] in their applications and services. Learn more at [Killrvideo].

We are now fully switched to use version `1.5.1` of the [DSE java driver][DSE Java driver]!  API docs are [here][DSE Java driver API docs].
This version is stable and ready for consumption.

## Running Locally

Use these guides to get started running KillrVideo locally on your development machine:
* [Getting Started with KillrVideo][getting-started]: Follow this to setup common dependencies like Docker.
* [Getting Started with Java][getting-started-java]: Follow this to get this Java code
running.

## Pull Requests, Requests for More Examples
This project will continue to evolve along with Cassandra and you can expect that as Cassandra and the DataStax
driver add new features. This sample application will try and provide examples of those.

We will gladly accept any pull requests for bug fixes, new features, etc.  and if you have a request for an example
that you don't see in the code currently, send me a message [@SonicDMG][twitter] or [@clunven][clunTwitter] on Twitter or open an issue
[here][issues] on GitHub.

## License
Copyright 2018 David Gilardi, Cedrick Lunven, derived from original work by Duy Hai Doan

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.

[cassandra]: http://cassandra.apache.org/
[dse]: http://www.datastax.com/products/datastax-enterprise
[Killrvideo]: https://killrvideo.github.io
[getting-started]: https://killrvideo.github.io/getting-started/
[getting-started-java]: https://killrvideo.github.io/docs/languages/java/
[twitter]: https://twitter.com/SonicDMG
[clunTwitter]: https://twitter.com/clunven
[DSE Java driver API docs]: https://github.com/datastax/java-dse-driver
[DSE Java driver]: https://docs.datastax.com/en/developer/java-driver-dse/1.5/
[issues]: https://github.com/KillrVideo/killrvideo-java/issues
[gremlindsljava]: https://www.datastax.com/dev/blog/gremlin-dsls-in-java-with-dse-graph

redpajama_set_name: RedPajamaGithub


text:
#ifndef _PNG_H
#define _PNG_H

/* This is not the place to learn how to use pnglib.  The file pnglib.txt
   describes how to use pnglib, and the file example.c summarizes it
   with some code to build around */

/* This file is arranged in several sections.  The first section contains
   all the definitions for pnglib.  The second section details the functions
   most users will use.  The third section describes the stub files that
   users will most likely need to change.  The last section contains
   functions used internally by the code.

   Any machine specific code is near the front of this file, so if you
   are configuring pnglib for a machine, you may want to read the section
   starting here down to where it starts to typedef png_color, png_text,
   and png_info */

/* this is the size of the compression buffer, and thus the size of
   an IDAT chunk.  Make this whatever size you feel is best for your
   machine.  One of these will be allocated per png_struct.  When this
   is full, it writes the data to the disk, and does some other
   calculations.  Making this an extreamly small size will slow
   the library down, but you may want to experiment to determine
   where it becomes significant, if you are conserned with memory
   usage.  Note that zlib allocates at least 32Kb also.  For readers,
   this describes the size of the buffer available to read the data in.
   Unless this gets smaller then the size of a row (compressed),
   it should not make much difference how big this is.  */

#define PNG_ZBUF_SIZE 8192;

/* include the compression library's header */
#include "zlib.h"

/* While pnglib currently uses zlib for it's compression, it has been designed
   to stand on it's own.  Towards this end, there are two defines that are
   used to help portability between machines.  To make it simpler to
   setup pnglib on a machine, this currently uses zlib's definitions, so
   any changes should be made in zlib. */

/* if you are running on a machine where you cannot allocate more then
   64K of memory, uncomment this.  While pnglib will not normally need
   that much memory in a chunk (unless you load up a very large file),
   zlib needs to know how big of a chunk it can use, and pnglib thus
   makes sure to check any memory allocation to verify it will fit
   into memory.
#define PNG_MAX_ALLOC_64K
*/
#ifdef MAXSEG_64K
#define PNG_MAX_ALLOC_64K
#endif

/* this macro protects us against machines that don't have function
   prototypes.  If your compiler does not handle function prototypes,
   define this macro.  I've always been able to use _NO_PROTO as the
   indicator, but you may need to drag the empty declaration out in
   front of here, or change the ifdef to suit your own needs. */
#ifndef PNGARG

#ifdef __P
#define PNGARG(arglist) __P(arglist)
#else

#ifdef _NO_PROTO
#define PNGARG(arglist)
#else
#define PNGARG(arglist) arglist
#endif /* _NO_PROTO */

#endif /* __P(arglist) */

#endif /* PNGARG */

/* enough people need this for various reasons to include it here */
#include <sys/types.h>
/* need the time information for reading tIME chunks */
#include <time.h>

/* for FILE.  If you are not using standard io, you don't need this */
#include <stdio.h>

/* include setjmp.h for error handling */
#include <setjmp.h>

/* other defines for things like memory and the like can go here.  These
   are the only files included in pnglib, so if you need to change them,
   change them here.  They are only included if PNG_INTERNAL is defined. */
#ifdef PNG_INTERNAL
#include <stdlib.h>
#include <ctype.h>
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
#include <math.h>

/* other defines specific to compilers can go here.  Try to keep
   them inside an appropriate ifdef/endif pair for portability */

/* for some reason, Borland C++ defines memcmp, etc. in mem.h, not
   stdlib.h like it should (I think).  Or perhaps this is a C++
   feature */
#ifdef __TURBOC__
#include <mem.h>
#include "alloc.h"
#endif

#ifdef _MSC_VER
#include <malloc.h>
#endif

/* this controls how fine the dithering gets.  As this allocates
   a largish chunk of memory (32K), those who are not as concerned
   with dithering quality can decrease some or all of these */
#define PNG_DITHER_RED_BITS 5
#define PNG_DITHER_GREEN_BITS 5
#define PNG_DITHER_BLUE_BITS 5

#endif /* PNG_INTERNAL */

/* some typedefs to get us started.  These should be safe on most of the
   common platforms.  The typedefs should be at least as large
   as the numbers suggest (a png_uint_32 must be at least 32 bits long),
   but they don't have to be exactly that size. */

typedef unsigned long png_uint_32;
typedef long png_int_32;
typedef unsigned short png_uint_16;
typedef short png_int_16;
typedef unsigned char png_byte;

/* this is usually size_t. it is typedef'ed just in case you need it to
   change (I'm not sure if you will or not, so I thought I'd be safe) */
typedef size_t png_size_t;

/* three color definitions.  The order of the red, green, and blue, (and the
   exact size) is not important, although the size of the fields need to
   be png_byte or png_uint_16 (as defined below).  While png_color_8 and
   png_color_16 have more fields then they need, they are never used in
   arrays, so the size isn't that important.  I thought about using
   unions, but it looked too clumsy, so I left it. If you're using C++,
   you can union red, index, and gray, if you want. */
typedef struct png_color_struct
{
   png_byte red;
   png_byte green;
   png_byte blue;
} png_color;

typedef struct png_color_16_struct
{
   png_byte index; /* used for palette files */
   png_uint_16 red; /* for use in red green blue files */
   png_uint_16 green;
   png_uint_16 blue;
   png_uint_16 gray; /* for use in grayscale files */
} png_color_16;

typedef struct png_color_8_struct
{
   png_byte red; /* for use in red green blue files */
   png_byte green;
   png_byte blue;
   png_byte gray; /* for use in grayscale files */
   png_byte alpha; /* for alpha channel files */
} png_color_8;

/* png_text holds the text in a png file, and whether they are compressed
   or not.  If compression is -1, the text is not compressed.  */
typedef struct png_text_struct
{
   int compression; /* compression value, -1 if uncompressed */
   char *key; /* keyword */
   char *text; /* comment */
   png_uint_32 text_length; /* length of text field */
} png_text;

/* png_time is a way to hold the time in an machine independent way.
   Two conversions are provided, both from time_t and struct tm.  There
   is no portable way to convert to either of these structures. */
typedef struct png_time_struct
{
   png_uint_16 year; /* full year, as in, 1995 */
   png_byte month; /* month of year, 1 - 12 */
   png_byte day; /* day of month, 1 - 31 */
   png_byte hour; /* hour of day, 0 - 23 */
   png_byte minute; /* minute of hour, 0 - 59 */
   png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
} png_time;

/* png_info is a structure that holds the information in a png file.
   If you are reading the file, This structure will tell you what is
   in the png file.  If you are writing the file, fill in the information
   you want to put into the png file, then call png_write_info().
   The names chosen should be very close to the PNG
   specification, so consult that document for information
   about the meaning of each field. */
typedef struct png_info_struct
{
   /* the following are necessary for every png file */
   png_uint_32 width; /* with of file */
   png_uint_32 height; /* height of file */
   png_byte bit_depth; /* 1, 2, 4, 8, or 16 */
   png_byte color_type; /* use the PNG_COLOR_TYPE_ defines */
   png_byte compression_type; /* must be 0 */
   png_byte filter_type; /* must be 0 */
   png_byte interlace_type; /* 0 for non-interlaced, 1 for interlaced */
   png_uint_32 valid; /* the PNG_INFO_ defines, OR'd together */
   /* the rest are optional.  If you are reading, check the valid
      field to see if the information in these are valid.  If you
      are writing, set the valid field to those chunks you want
      written, and initialize the appropriate fields below */
   float gamma; /* gamma value of file, if gAMA chunk is valid */
   png_color_8 sig_bit; /* significant bits */
   float x_white; /* cHRM chunk values */
   float y_white;
   float x_red;
   float y_red;
   float x_green;
   float y_green;
   float x_blue;
   float y_blue;
   png_color *palette; /* palette of file */
   png_uint_16 num_palette; /* number of values in palette */
   png_byte *trans; /* tRNS values for palette image */
    png_uint_16 num_trans; /* number of trans values */
   png_color_16 trans_values; /* tRNS values for non-palette image */
   png_color_16 background; /* background color of image */
   png_uint_16 *hist; /* histogram of palette usage */
   png_uint_32 x_pixels_per_unit; /* x resolution */
   png_uint_32 y_pixels_per_unit; /* y resolution */
   png_byte phys_unit_type; /* resolution type */
   png_uint_32 x_offset; /* x offset on page */
   png_uint_32 y_offset; /* y offset on page */
   png_byte offset_unit_type; /* offset units type */
   png_time mod_time; /* modification time */
   int num_text; /* number of comments */
   int max_text; /* size of text array */
   png_text *text; /* array of comments */
} png_info;

#define PNG_RESOLUTION_UNKNOWN 0
#define PNG_RESOLUTION_METER 1

#define PNG_OFFSET_PIXEL 0
#define PNG_OFFSET_MICROMETER 1

/* these describe the color_type field in png_info */

/* color type masks */
#define PNG_COLOR_MASK_PALETTE 1
#define PNG_COLOR_MASK_COLOR 2
#define PNG_COLOR_MASK_ALPHA 4

/* color types.  Note that not all combinations are legal */
#define PNG_COLOR_TYPE_PALETTE \
   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
#define PNG_COLOR_TYPE_GRAY 0
#define PNG_COLOR_TYPE_RGB_ALPHA \
   (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)

/* These determine if a chunks information is present in a read operation, or
   if the chunk should be written in a write operation.  */
#define PNG_INFO_gAMA 0x0001
#define PNG_INFO_sBIT 0x0002
#define PNG_INFO_cHRM 0x0004
#define PNG_INFO_PLTE 0x0008
#define PNG_INFO_tRNS 0x0010
#define PNG_INFO_bKGD 0x0020
#define PNG_INFO_hIST 0x0040
#define PNG_INFO_pHYs 0x0080
#define PNG_INFO_oFFs 0x0100
#define PNG_INFO_tIME 0x0200

/* this is used for the transformation routines, as some of them
   change these values for the row.  It also should enable using
   the routines for other uses. */
typedef struct png_row_info_struct
{
   png_uint_32 width; /* width of row */
   png_uint_32 rowbytes; /* number of bytes in row */
   png_byte color_type; /* color type of row */
   png_byte bit_depth; /* bit depth of row */
   png_byte channels; /* number of channels (1, 2, 3, or 4) */
   png_byte pixel_depth; /* bits per pixel (depth * channels) */
} png_row_info;

/* The structure that holds the information to read and write png files.
   The only people who need to care about what is inside of this are the
   people who will be modifying the library for their own special needs.
   */
typedef struct png_struct_def
{
   jmp_buf jmpbuf; /* used in png_error */
   png_byte mode; /* used to determine where we are in the png file */
   png_byte color_type; /* color type of file */
   png_byte bit_depth; /* bit depth of file */
   png_byte interlaced; /* interlace type of file */
   png_byte compession; /* compression type of file */
   png_byte filter; /* filter type */
   png_byte channels; /* number of channels in file */
   png_byte pixel_depth; /* number of bits per pixel */
   png_byte usr_bit_depth; /* bit depth of users row */
   png_byte usr_channels; /* channels at start of write */
   png_byte gamma_shift; /* amount of shift for 16 bit gammas */
   png_byte shift; /* shift for significant bit tranformation */
   png_byte pass; /* current pass (0 - 6) */
   png_byte row_init; /* 1 if png_read_start_row() has been called */
   png_uint_16 num_palette; /* number of entries in palette */
   png_uint_16 num_trans; /* number of transparency values */
   png_uint_32 transformations; /* which transformations to perform */
   png_uint_32 crc; /* current crc value */
   png_uint_32 width; /* width of file */
   png_uint_32 height; /* height of file */
   png_uint_32 num_rows; /* number of rows in current pass */
   png_uint_32 rowbytes; /* size of row in bytes */
   png_uint_32 usr_width; /* width of row at start of write */
   png_uint_32 iwidth; /* interlaced width */
   png_uint_32 irowbytes; /* interlaced rowbytes */
   png_uint_32 row_number; /* current row in pass */
   png_uint_32 idat_size; /* current idat size for read */
   png_uint_32 zbuf_size; /* size of zbuf */
   png_color *palette; /* files palette */
   png_byte *palette_lookup; /* lookup table for dithering */
   png_byte *gamma_table; /* gamma table for 8 bit depth files */
   png_byte *gamma_from_1; /* converts from 1.0 to screen */
   png_byte *gamma_to_1; /* converts from file to 1.0 */
   png_byte *trans; /* transparency values for paletted files */
   png_byte *dither_index; /* index translation for palette files */
   png_uint_16 **gamma_16_table; /* gamma table for 16 bit depth files */
   png_uint_16 **gamma_16_from_1; /* converts from 1.0 to screen */
   png_uint_16 **gamma_16_to_1; /* converts from file to 1.0 */
   png_uint_16 *hist; /* histogram */
   png_byte *zbuf; /* buffer for zlib */
   png_byte *row_buf; /* row buffer */
   png_byte *prev_row; /* previous row */
   png_byte *save_row; /* place to save row before filtering */
   z_stream *zstream; /* pointer to decompression structure (below) */
   float gamma; /* file gamma value */
   float display_gamma; /* display gamma value */
   png_color_8 sig_bit; /* significant bits in file */
   png_color_16 trans_values; /* transparency values for non-paletted files */
   png_color_16 background; /* background color */
   png_row_info row_info; /* used for transformation routines */
   z_stream zstream_struct; /* decompression structure */
   FILE *fp; /* used for png_read and png_write */
} png_struct;

/* Here are the function definitions most commonly used.  This is not
   the place to find out how to use pnglib.  See pnglib.txt for the
   full explanation, see example.c for the summary.  This just provides
   a simple one line of the use of each function. */

/* check the first 1 - 8 bytes to see if it is a png file */
extern int png_check_sig PNGARG((png_byte *sig, int num));

/* initialize png structure for reading, and allocate any memory needed */
extern void png_read_init PNGARG((png_struct *png_ptr));

/* initialize png structure for writing, and allocate any memory needed */
extern void png_write_init PNGARG((png_struct *png_ptr));

/* initialize the info structure */
extern void png_info_init PNGARG((png_info *info));

/* Writes all the png information before the image. */
extern void png_write_info PNGARG((png_struct *png_ptr, png_info *info));

/* read the information before the actual image data. */
extern void png_read_info PNGARG((png_struct *png_ptr, png_info *info));

/* convert from a struct tm to png_time */
extern void png_convert_from_struct_tm PNGARG((png_time *ptime,
   struct tm *ttime));

/* convert from time_t to png_time.  Uses gmtime() */
extern void png_convert_from_time_t PNGARG((png_time *ptime, time_t ttime));

/* Expand the data to 24 bit RGB, or 8 bit Grayscale,
   with alpha if necessary. */
extern void png_set_expand PNGARG((png_struct *png_ptr));

/* Use blue, green, red order for pixels. */
extern void png_set_bgr PNGARG((png_struct *png_ptr));

/* Add a filler byte to rgb images. */
extern void png_set_rgbx PNGARG((png_struct *png_ptr));

/* Swap bytes in 16 bit depth files. */
extern void png_set_swap PNGARG((png_struct *png_ptr));

/* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
extern void png_set_packing PNGARG((png_struct *png_ptr));

/* Converts files to legal bit depths. */
extern void png_set_shift PNGARG((png_struct *png_ptr, int true_bits));

/* Have the code handle the interlacing.  Returns the number of passes. */
extern int png_set_interlace_handling PNGARG((png_struct *png_ptr));

/* Invert monocrome files */
extern void png_set_invert_mono PNGARG((png_struct *png_ptr));

/* Handle alpha and tRNS by using previous info in row buffer. */
extern void png_set_alpha PNGARG((png_struct *png_ptr));

/* Handle alpha and tRNS by replacing with a background color. */
extern void png_set_background PNGARG((png_struct *png_ptr,
   png_color_16 *background_color));

/* strip the second byte of information from a 16 bit depth file. */
extern void png_set_strip_16 PNGARG((png_struct *png_ptr));

/* convert a grayscale file into rgb. */
extern void png_set_gray_to_rgb PNGARG((png_struct *png_ptr));

/* Turn on dithering, and reduce the palette to the number of colors available. */
extern void png_set_dither PNGARG((png_struct *png_ptr, png_color *palette,
   int num_palette, int maximum_colors, png_uint_16 *histogram, int full_dither));

/* Handle gamma correction. */
extern void png_set_gamma PNGARG((png_struct *png_ptr, float screen_gamma,
   float default_file_gamma));

/* optional update palette with requested transformations */
void png_start_read_image PNGARG((png_struct *png_ptr));

/* read a one or more rows of image data.*/
extern void png_read_rows PNGARG((png_struct *png_ptr,
   png_byte **row,
   png_byte **display_row, png_uint_32 num_rows));

/* read a row of data.*/
extern void png_read_row PNGARG((png_struct *png_ptr,
   png_byte *row,
   png_byte *display_row));

/* read the whole image into memory at once. */
extern void png_read_image PNGARG((png_struct *png_ptr,
   png_byte **image));

/* write a row of image data */
extern void png_write_row PNGARG((png_struct *png_ptr,
   png_byte *row));

/* write a few rows of image data */
extern void png_write_rows PNGARG((png_struct *png_ptr,
   png_byte **row,
   png_uint_32 num_rows));

/* write the image data */
extern void png_write_image PNGARG((png_struct *png_ptr, png_byte **image));

/* writes the end of the png file. */
extern void png_write_end PNGARG((png_struct *png_ptr, png_info *info));

/* read the end of the png file. */
extern void png_read_end PNGARG((png_struct *png_ptr, png_info *info));

/* free all memory used by the read */
extern void png_read_destroy PNGARG((png_struct *png_ptr, png_info *info));

/* free any memory used in png struct */
extern void png_write_destroy PNGARG((png_struct *png_ptr));

/* These next functions are stubs of typical c functions for input/output,
   memory, and error handling.  They are in the file pngstub.c, and are
   set up to be easily modified for users that need to.  See the file
   pngstub.c for more information */

/* Write the data to whatever output you are using. */
extern void png_write_data PNGARG((png_struct *png_ptr, png_byte *data,
   png_uint_32 length));

/* Read data from whatever input you are using */
extern void png_read_data PNGARG((png_struct *png_ptr, png_byte *data,
   png_uint_32 length));

/* Initialize the input/output for the png file. */
extern void png_init_io PNGARG((png_struct *png_ptr, FILE *fp));

/* Allocate memory in larger chunks. */
extern void *png_large_malloc PNGARG((png_struct *png_ptr, png_uint_32 size));

/* free's a pointer allocated by png_large_malloc() */
extern void png_large_free PNGARG((png_struct *png_ptr, void *ptr));

/* Allocate memory. */
extern void *png_malloc PNGARG((png_struct *png_ptr, png_uint_32 size));

/* Reallocate memory. */
extern void *png_realloc PNGARG((png_struct *png_ptr, void *ptr,
   png_uint_32 size));

/* free's a pointer allocated by png_malloc() */
extern void png_free PNGARG((png_struct *png_ptr, void *ptr));

/* Fatal error in pnglib - can't continue */
extern void png_error PNGARG((png_struct *png_ptr, char *error));

/* Non-fatal error in pnglib.  Can continue, but may have a problem. */
extern void png_warning PNGARG((png_struct *png_ptr, char *message));

/* These next functions are used internally in the code.  If you use
   them, make sure you read and understand the png spec.  More information
   about them can be found in the files where the functions are.
   Feel free to move any of these outside the PNG_INTERNAL define if
   you just need a few of them, but if you need access to more, you should
   define PNG_INTERNAL inside your code, so everyone who includes png.h
   won't get yet another definition the compiler has to deal with. */

#ifdef PNG_INTERNAL

/* various modes of operation.  Note that after an init, mode is set to
   zero automatically */
#define PNG_BEFORE_IHDR 0
#define PNG_HAVE_IHDR 1
#define PNG_HAVE_PLTE 2
#define PNG_HAVE_IDAT 3
#define PNG_AT_LAST_IDAT 4
#define PNG_AFTER_IDAT 5
#define PNG_AFTER_IEND 6

/* defines for the transformations the png library does on the image data */
#define PNG_BGR 0x0001
#define PNG_INTERLACE 0x0002
#define PNG_PACK 0x0004
#define PNG_SHIFT 0x0008
#define PNG_SWAP_BYTES 0x0010
#define PNG_INVERT_MONO 0x0020
#define PNG_DITHER 0x0040
#define PNG_BACKGROUND 0x0080
#define PNG_ALPHA 0x0100
#define PNG_16_TO_8 0x0200
#define PNG_RGBA 0x0400
#define PNG_EXPAND 0x0800
#define PNG_GAMMA 0x1000
#define PNG_GRAY_TO_RGB 0x2000

/* save typing and make code easier to understand */
#define PNG_COLOR_DIST (c1, c2) (abs((c1).red - (c2).red) + \
   abs((c1).green - (c2).green) + abs((c1).blue - (c2).blue))

/* variables defined in png.c - only it needs to define PNG_NO_EXTERN */
#ifndef PNG_NO_EXTERN
/* place to hold the signiture string for a png file. */
extern png_byte png_sig[];

/* constant strings for known chunk types.  If you need to add a chunk,
   add a string holding the name here.  See png.c for more details */
extern png_byte png_IHDR[];
extern png_byte png_IDAT[];
extern png_byte png_IEND[];
extern png_byte png_PLTE[];
extern png_byte png_gAMA[];
extern png_byte png_sBIT[];
extern png_byte png_cHRM[];
extern png_byte png_tRNS[];
extern png_byte png_bKGD[];
extern png_byte png_hIST[];
extern png_byte png_tEXt[];
extern png_byte png_zTXt[];
extern png_byte png_pHYs[];
extern png_byte png_oFFs[];
extern png_byte png_tIME[];
/* Structures to facilitate easy interlacing.  See png.c for more details */
extern int png_pass_start[];
extern int png_pass_inc[];
extern int png_pass_ystart[];
extern int png_pass_yinc[];
/* these are not currently used.  If you need them, see png.c
extern int png_pass_width[];
extern int png_pass_height[];
*/
extern int png_pass_mask[];
extern int png_pass_dsp_mask[];

#endif /* PNG_NO_EXTERN */

/* Function to allocate memory for zlib. */
extern voidp png_zalloc PNGARG((voidp png_ptr, uInt items, uInt size));

/* function to free memory for zlib */
extern void png_zfree PNGARG((voidp png_ptr, voidp ptr));

/* reset the crc variable */
extern void png_reset_crc PNGARG((png_struct *png_ptr));

/* calculate the crc over a section of data.  Note that while we
   are passing in a 32 bit value for length, on 16 bit machines, you
   would need to use huge pointers to access all that data.  See the
   code in png.c for more information. */
extern void png_calculate_crc PNGARG((png_struct *png_ptr, png_byte *ptr,
   png_uint_32 length));

/* place a 32 bit number into a buffer in png byte order.  We work
   with unsigned numbers for convenience, you may have to cast
   signed numbers (if you use any, most png data is unsigned). */
extern void png_save_uint_32 PNGARG((png_byte *buf, png_uint_32 i));

/* place a 16 bit number into a buffer in png byte order */
extern void png_save_uint_16 PNGARG((png_byte *buf, png_uint_16 i));

/* write a 32 bit number */
extern void png_write_uint_32 PNGARG((png_struct *png_ptr, png_uint_32 i));

/* write a 16 bit number */
extern void png_write_uint_16 PNGARG((png_struct *png_ptr, png_uint_16 i));

/* Write a png chunk.  */
extern void png_write_chunk PNGARG((png_struct *png_ptr, png_byte *type,
   png_byte *data, png_uint_32 length));

/* Write the start of a png chunk. */
extern void png_write_chunk_start PNGARG((png_struct *png_ptr, png_byte *type,
   png_uint_32 total_length));

/* write the data of a png chunk started with png_write_chunk_start(). */
extern void png_write_chunk_data PNGARG((png_struct *png_ptr, png_byte *data,
   png_uint_32 length));

/* finish a chunk started with png_write_chunk_start() */
extern void png_write_chunk_end PNGARG((png_struct *png_ptr));

/* simple function to write the signiture */
extern void png_write_sig PNGARG((png_struct *png_ptr));

/* write various chunks */

/* Write the IHDR chunk, and update the png_struct with the necessary
   information. */
extern void png_write_IHDR PNGARG((png_struct *png_ptr, png_uint_32 width,
   png_uint_32 height,
   int bit_depth, int color_type, int compression_type, int filter_type,
   int interlace_type));

extern void png_write_PLTE PNGARG((png_struct *png_ptr, png_color *palette,
   int number));

extern void png_write_IDAT PNGARG((png_struct *png_ptr, png_byte *data,
   png_uint_32 length));

extern void png_write_IEND PNGARG((png_struct *png_ptr));

extern void png_write_gAMA PNGARG((png_struct *png_ptr, float gamma));

extern void png_write_sBIT PNGARG((png_struct *png_ptr, png_color_8 *sbit,
   int color_type));

extern void png_write_cHRM PNGARG((png_struct *png_ptr,
   float white_x, float white_y,
   float red_x, float red_y, float green_x, float green_y,
   float blue_x, float blue_y));

extern void png_write_tRNS PNGARG((png_struct *png_ptr, png_byte *trans,
   png_color_16 *values, int number, int color_type));

extern void png_write_bKGD PNGARG((png_struct *png_ptr, png_color_16 *values,
   int color_type));

extern void png_write_hIST PNGARG((png_struct *png_ptr, png_uint_16 *hist,
   int number));

extern void png_write_tEXt PNGARG((png_struct *png_ptr, char *key,
   char *text, png_uint_32 text_len));

extern void png_write_zTXt PNGARG((png_struct *png_ptr, char *key,
   char *text, png_uint_32 text_len, int compression));

extern void png_write_pHYs PNGARG((png_struct *png_ptr,
   png_uint_32 x_pixels_per_unit,
   png_uint_32 y_pixels_per_unit,
   int unit_type));

extern void png_write_oFFs PNGARG((png_struct *png_ptr,
   png_uint_32 x_offset,
   png_uint_32 y_offset,
   int unit_type));

extern void png_write_tIME PNGARG((png_struct *png_ptr, png_time *mod_time));

/* Internal use only.   Called when finished processing a row of data */
extern void png_write_finish_row PNGARG((png_struct *png_ptr));

/* Internal use only.   Called before first row of data */
extern void png_write_start_row PNGARG((png_struct *png_ptr));

/* callbacks for png chunks */
extern void png_read_IHDR PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 width, png_uint_32 height, int bit_depth,
   int color_type, int compression_type, int filter_type,
   int interlace_type));
extern void png_read_PLTE PNGARG((png_struct *png_ptr, png_info *info,
   png_color *palette, int num));
extern void png_read_gAMA PNGARG((png_struct *png_ptr, png_info *info,
   float gamma));
extern void png_read_sBIT PNGARG((png_struct *png_ptr, png_info *info,
   png_color_8 *sig_bit));
extern void png_read_cHRM PNGARG((png_struct *png_ptr, png_info *info,
   float white_x, float white_y, float red_x, float red_y,
   float green_x, float green_y, float blue_x, float blue_y));
extern void png_read_tRNS PNGARG((png_struct *png_ptr, png_info *info,
   png_byte *trans, int num_trans,   png_color_16 *trans_values));
extern void png_read_bKGD PNGARG((png_struct *png_ptr, png_info *info,
   png_color_16 *background));
extern void png_read_hIST PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_16 *hist));
extern void png_read_pHYs PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 res_x, png_uint_32 res_y, int unit_type));
extern void png_read_oFFs PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 offset_x, png_uint_32 offset_y, int unit_type));
extern void png_read_tIME PNGARG((png_struct *png_ptr, png_info *info,
   png_time *mod_time));
extern void png_read_tEXt PNGARG((png_struct *png_ptr, png_info *info,
   char *key, char *text, png_uint_32 text_len));
extern void png_read_zTXt PNGARG((png_struct *png_ptr, png_info *info,
   char *key, char *text, png_uint_32 text_len, int compression));

void
png_build_gamma_table PNGARG((png_struct *png_ptr));

/* combine a row of data, dealing with alpha, etc. if requested */
extern void png_combine_row PNGARG((png_struct *png_ptr, png_byte *row,
   png_byte *ref, int mask));
/* expand an interlaced row */
extern void png_do_read_interlace PNGARG((png_row_info *row_info,
   png_byte *row, int pass));
/* grab pixels out of a row for an interlaced pass */
extern void png_do_write_interlace PNGARG((png_row_info *row_info,
   png_byte *row, int pass));

/* unfilter a row */
extern void png_read_filter_row PNGARG((png_row_info *row_info,
   png_byte *row, png_byte *prev_row, int filter));
/* filter a row, and place the correct filter byte in the row */
extern void png_write_filter_row PNGARG((png_row_info *row_info,
   png_byte *row, png_byte *prev_row));
/* finish a row while reading, dealing with interlacing passes, etc. */
extern void png_read_finish_row PNGARG((png_struct *png_ptr));
/* initialize the row buffers, etc. */
extern void png_read_start_row PNGARG((png_struct *png_ptr));

/* these are the functions that do the transformations */
extern void png_do_read_rgbx PNGARG((png_row_info *row_info,
   png_byte *row));
extern void png_do_write_rgbx PNGARG((png_row_info *row_info,
   png_byte *row));
extern void png_do_swap PNGARG((png_row_info *row_info, png_byte *row));
extern void png_do_unpack PNGARG((png_row_info *row_info, png_byte *row));
extern void png_do_unshift PNGARG((png_row_info *row_info, png_byte *row,
   int sig_bits));
extern void png_do_invert PNGARG((png_row_info *row_info, png_byte *row));
extern void png_do_gray_to_rgb PNGARG((png_row_info *row_info,
   png_byte *row));
extern void png_do_chop PNGARG((png_row_info *row_info, png_byte *row));
extern void png_do_dither PNGARG((png_row_info *row_info,
   png_byte *row, png_byte *palette_lookup));
extern void png_do_bgr PNGARG((png_row_info *row_info, png_byte *row));
extern void png_do_pack PNGARG((png_row_info *row_info,
   png_byte *row, png_byte bit_depth));
extern void png_do_shift PNGARG((png_row_info *row_info, png_byte *row,
   int bit_depth));
extern void png_do_background PNGARG((png_row_info *row_info, png_byte *row,
   png_color_16 *trans_values, png_color_16 *background,
   int trans_num, png_byte *trans,
   png_byte *gamma_table, png_byte *gamma_from_1, png_byte *gamma_to_1,
   png_uint_16 **gamma_16, png_uint_16 **gamma_16_from_1,
   png_uint_16 **gamma_16_to_1, int png_shift));
extern void png_do_gamma PNGARG((png_row_info *row_info, png_byte *row,
   png_byte *gamma_table, png_uint_16 **gamma_16_table,
   int gamma_shift));
extern void png_do_expand_palette PNGARG((png_row_info *row_info,
   png_byte *row, png_color *palette, png_byte *trans, int num_trans));
extern void png_do_expand PNGARG((png_row_info *row_info,
   png_byte *row, png_color_16 *trans_value));

/* unpack 16 and 32 bit values from a string */
extern png_uint_32 png_get_uint_32 PNGARG((png_byte *buf));
extern png_uint_16 png_get_uint_16 PNGARG((png_byte *buf));

/* read bytes into buf, and update png_ptr->crc */
extern void png_crc_read PNGARG((png_struct *png_ptr, png_byte *buf,
   png_uint_32 length));
/* skip length bytes, and update png_ptr->crc */
extern void png_crc_skip PNGARG((png_struct *png_ptr, png_uint_32 length));

/* the following decodes the appropriate chunks, and does error correction,
   then calls the appropriate callback for the chunk if it is valid */

/* decode the IHDR chunk */
extern void png_handle_IHDR PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_PLTE PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_gAMA PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_sBIT PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_cHRM PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_tRNS PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_bKGD PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_hIST PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_pHYs PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_oFFs PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_tIME PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_tEXt PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_handle_zTXt PNGARG((png_struct *png_ptr, png_info *info,
   png_uint_32 length));
extern void png_combine_row PNGARG((png_struct *png_ptr, png_byte *row,
   png_byte *ref, int mask));

/* handle the transformations for reading and writing */
extern void png_do_read_transformations PNGARG((png_struct *png_ptr));
extern void png_do_write_transformations PNGARG((png_struct *png_ptr));

#endif /* PNG_INTERNAL */

/* do not put anything past this line */
#endif /* _PNG_H */


text:
//
//  SendOrderViewController.m
//  SmallPig
//
//  Created by clei on 15/3/11.
//  Copyright (c) 2015年 chenlei. All rights reserved.
//

#import "SendOrderViewController.h"
#import "FindUserViewController.h"
#import "LeftRightLableCell.h"
#import "SavePublicCell.h"
#import "AgentHouseListViewController.h"
#import "ServiceListViewController.h"

@interface SendOrderViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSString *userID;
@property (nonatomic, strong) NSString *userName;
@property (nonatomic, strong) NSString *time;
@property (nonatomic, strong) NSString *serviceName;
@property (nonatomic, strong) NSString *serviceID;
@property (nonatomic, strong) NSDictionary *houseDic;
@property (nonatomic, strong) NSString *roomID;
@end

@implementation SendOrderViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    //设置title
    self.title = @"创建订单";
    //添加item
    [self addBackItem];
    [self setNavBarItemWithTitle:@"发送" navItemType:rightItem selectorName:@"sendButtonPressed:"];
    //初始化UI
    [self createUI];
    self.dataArray = (NSMutableArray *)@[@[@" 客户",@" 房源详情"],@[@" 跟单人"]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(findUser:) name:@"FindUser" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(houseDetail:) name:@"HouseDetail" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(findService:) name:@"FindService" object:nil];

    // Do any additional setup after loading the view.
}

#pragma mark 初始化UI
- (void)createUI
{
    [self addTableView];
}

- (void)addTableView
{
    [self addTableViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) tableType:UITableViewStyleGrouped tableDelegate:self];
}

#pragma mark 发送
- (void)sendButtonPressed:(UIButton *)sender
{
    if (self.userName && self.houseDic && self.serviceName)
    {
        [self sendOrder];
    }
    else
    {
        [CommonTool addAlertTipWithMessage:@"订单数据不完整"];
    }
}

- (void)sendOrder
{
     [SVProgressHUD showWithStatus:@"发送中..."];
    NSString *price = [NSString stringWithFormat:@"%.0f",[self.houseDic[@"price"] floatValue]];
    NSDictionary *rquestDic = @{@"publishRoom.id":self.roomID,@"buyer.id":self.userID,@"buyerName":self.userName,@"buyerNid":@"",@"servicer.id":self.serviceID,@"price":price,@"bookPrice":@"100"};
    RequestTool *request = [[RequestTool alloc] init];
    [request requestWithUrl:SEND_ORDER_URL requestParamas:rquestDic requestType:RequestTypeAsynchronous requestSucess:
     ^(AFHTTPRequestOperation *operation, id responseDic)
     {
         NSLog(@"responseDic===%@",operation.responseString);
         NSDictionary *dic = (NSDictionary *)responseDic;
         int sucess = [dic[@"responseMessage"][@"success"] intValue];
         if (sucess == 1)
         {
             [SVProgressHUD showSuccessWithStatus:@"发送成功"];
             [CommonTool addAlertTipWithMessage:@"发送成功"];
             [self.navigationController popToViewController:self.navigationController.viewControllers[2] animated:YES];
         }
         else
         {
             [SVProgressHUD showErrorWithStatus:@"发送失败"];
             [CommonTool addAlertTipWithMessage:[@"发送失败 " stringByAppendingString:dic[@"responseMessage"][@"message"]]];
         }
     }
                requestFail:^(AFHTTPRequestOperation *operation, NSError *error)
     {
         [SVProgressHUD showErrorWithStatus:@"发送失败"];
         [CommonTool addAlertTipWithMessage:@"发送失败"];
     }];
}

#pragma mark 查找用户
- (void)findUser:(NSNotification *)notification
{
    NSDictionary *dic = (NSDictionary *)notification.object;
    self.userID = (dic[@"id"]) ? dic[@"id"] : @"";
    self.userName = (dic[@"name"]) ? dic[@"name"] : @"";
    [self.table reloadData];
}

#pragma mark 选择房源
- (void)houseDetail:(NSNotification *)notification
{
    self.houseDic = (NSDictionary *)notification.object;
    if (self.houseDic)
    {
        NSString *roomID = self.houseDic[@"room"][@"id"];
        roomID = (roomID) ? roomID : @"";
        self.roomID = roomID;
        int roomType = [self.houseDic[@"roomType"] intValue];
        if (roomType == 3)
        {
            self.time = [NSString  stringWithFormat:@"%d",[self.houseDic[@"period"] intValue]];
            self.time = (self.time) ? [self.time stringByAppendingString:@"个月"] : @"";
            self.dataArray = (NSMutableArray *)@[@[@" 客户",@" 房源详情",@" 租期"],@[@" 跟单人"]];
        }
        else
        {
            self.dataArray = (NSMutableArray *)@[@[@" 客户",@" 房源详情"],@[@" 跟单人"]];
        }
    }
    [self.table reloadData];
}

#pragma mark 选择客服
- (void)findService:(NSNotification *)notification
{
    NSDictionary *dic = (NSDictionary *)notification.object;
    self.serviceID = (dic[@"id"]) ? dic[@"id"] : @"";
    self.serviceName = (dic[@"name"]) ? dic[@"name"] : @"";
    [self.table reloadData];
}

#pragma mark - tableView代理

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 15.0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIImageView *imageView = [CreateViewTool createImageViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 15.0) placeholderImage:nil];
    imageView.backgroundColor = [UIColor clearColor];
    return imageView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.houseDic && indexPath.row == 1 && indexPath.section ==0)
    {
        return SAVE_LIST_HEIGHT;
    }
    return 44.0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [self.dataArray count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.dataArray[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *leftRightCellID = @"LeftRightCellID";
    static NSString *houseCellID = @"HouseCellID";
    UITableViewCell *cell;
    if (indexPath.section == 0 && indexPath.row == 1 && self.houseDic)
    {
        cell = (SavePublicCell *)[tableView dequeueReusableCellWithIdentifier:houseCellID];
        if (!cell)
        {
            cell = [[SavePublicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:houseCellID];
        }
        cell.accessoryType = UITableViewCellAccessoryNone;
        if (self.houseDic)
        {
            NSDictionary *rowDic = self.houseDic;
            NSString *title = rowDic[@"title"];
            title = (title) ? title : @"";
            NSString *imageUrl = [SmallPigTool makePhotoUrlWithPhotoUrl:rowDic[@"coverPhoto"][@"photoUrl"] photoSize:HOUSE_LIST_ICON_SIZE photoType:rowDic[@"coverPhoto"][@"photoType"]];
            NSLog(@"imageUrl===%@",imageUrl );
            NSString *local = rowDic[@"room"][@"community"][@"address"];
            local = (local) ? local : @"";
            NSLog(@"local===%@",local);
            NSString *park = rowDic[@"room"][@"community"][@"name"];
            park = (park) ? park : @"";
            NSString *square = [NSString stringWithFormat:@"%@平米",rowDic[@"room"][@"square"]];
            square = (square) ? square : @"";
            NSString *roomStyle = [SmallPigTool makeEasyRoomStyleWithRoomDictionary:rowDic];
            int roomType = [rowDic[@"roomType"] intValue];
            float price = (roomType == 3 ) ? [rowDic[@"price"] floatValue] : [rowDic[@"price"] floatValue]/10000.0;
            NSString *roomPrice = (roomType == 3) ? [NSString stringWithFormat:@"%.0f元",price] : [NSString stringWithFormat:@"%.0f万",price];
            [(SavePublicCell *)cell setCellImageWithUrl:imageUrl titleText:title localText:local parkText:park priceText:roomPrice typeText:roomStyle sizeText:square];
        }

    }
    else
    {
        cell = (LeftRightLableCell *)[tableView dequeueReusableCellWithIdentifier:leftRightCellID];
        if (!cell)
        {
            cell = [[LeftRightLableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:leftRightCellID];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
        [(LeftRightLableCell *)cell setLeftColor:[UIColor blackColor] rightColor:HOUSE_DETAIL_TITLE_COLOR];
        NSString *rightStr = @"";
        if (indexPath.section == 0)
        {
            if (indexPath.row == 0)
            {
                rightStr = (self.userName) ? self.userName : @"";
            }
            if (indexPath.row == 2)
            {
                rightStr = (self.time) ? self.time : @"";
            }
        }
        if (indexPath.section == 1)
        {
            if (indexPath.row == 0)
            {
                rightStr = (self.serviceName) ? self.serviceName : @"";
            }
        }
        [(LeftRightLableCell *)cell setDataWithLeftText:self.dataArray[indexPath.section][indexPath.row] rightText:rightStr];
    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            FindUserViewController *findUserViewController = [[FindUserViewController alloc] init];
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:findUserViewController];
            [self presentViewController:nav animated:YES completion:Nil];
        }
        if (indexPath.row == 1)
        {
            if (!self.userName)
            {
               [CommonTool addAlertTipWithMessage:@"请选择客户"];
                return;
            }
            AgentHouseListViewController *houseListViewController = [[AgentHouseListViewController alloc] init];
            houseListViewController.isOnlyList = YES;
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:houseListViewController];
            [self presentViewController:nav animated:YES completion:Nil];
        }
    }
    else if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            if (![self isCanNext])
            {
                return;
            }
            ServiceListViewController *serviceListViewController = [[ServiceListViewController alloc] init];
            serviceListViewController.roomID = self.roomID;
            UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:serviceListViewController];
            [self presentViewController:nav animated:YES completion:Nil];
        }
    }
}

- (BOOL)isCanNext
{
    BOOL isNext = NO;
    NSString *message = @"";
    if (!self.userName)
    {
       message = @"请选择客户";
    }
    else if (!self.houseDic)
    {
        message = @"请选择房源";
    }
    if (message.length == 0)
    {
        isNext = YES;
    }
    else
    {
        isNext = NO;
        [CommonTool addAlertTipWithMessage:message];
    }
    return isNext;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


text:
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class template unordered_multimap</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../unordered/reference.html#header.boost.unordered_map_hpp" title="Header <boost/unordered_map.hpp>">
<link rel="prev" href="unordered_map.html" title="Class template unordered_map">
<link rel="next" href="../unordered/bibliography.html" title="Bibliography">

Home
Libraries
People
FAQ
More

Class template unordered_multimap

boost::unordered_multimap —
            An unordered associative container that associates keys with another value. The same key can be stored multiple times.

Synopsis

// In header: <boost/unordered_map.hpp>

template<typename Key, typename Mapped, typename Hash = boost::hash<Key>,
         typename Pred = std::equal_to<Key>,
         typename Alloc = std::allocator<std::pair<Key const, Mapped>> >
class unordered_multimap {
public:
  // types
  typedef Key                                    key_type;
  typedef std::pair<Key const, Mapped>           value_type;
  typedef Mapped                                 mapped_type;
  typedef Hash                                   hasher;
  typedef Pred                                   key_equal;
  typedef Alloc                                  allocator_type;
  typedef typename allocator_type::pointer       pointer;
  typedef typename allocator_type::const_pointer const_pointer;
  typedef value_type&                            reference;             // lvalue of value_type.
  typedef value_type const&                      const_reference;       // const lvalue of value_type.
  typedef implementation-defined                 size_type;
  typedef implementation-defined                 difference_type;
  typedef implementation-defined                 iterator;
  typedef implementation-defined                 const_iterator;
  typedef implementation-defined                 local_iterator;
  typedef implementation-defined                 const_local_iterator;

  // construct/copy/destruct
  explicit unordered_multimap(size_type = implementation-defined,
                              hasher const& = hasher(),
                              key_equal const& = key_equal(),
                              allocator_type const& = allocator_type());
  template<typename InputIterator>
    unordered_multimap(InputIterator, InputIterator,
                       size_type = implementation-defined,
                       hasher const& = hasher(),
                       key_equal const& = key_equal(),
                       allocator_type const& = allocator_type());
  unordered_multimap(unordered_multimap const&);
  unordered_multimap(unordered_multimap &&);
  explicit unordered_multimap(Allocator const&);
  unordered_multimap(unordered_multimap const&, Allocator const&);
  ~unordered_multimap();
  unordered_multimap& operator=(unordered_multimap const&);
  unordered_multimap& operator=(unordered_multimap &&);
  allocator_type get_allocator() const;

  // size and capacity
  bool empty() const;
  size_type size() const;
  size_type max_size() const;

  // iterators
  iterator begin();
  const_iterator begin() const;
  iterator end();
  const_iterator end() const;
  const_iterator cbegin() const;
  const_iterator cend() const;

  // modifiers
  template<typename... Args> iterator emplace(Args&&...);
  template<typename... Args> iterator emplace_hint(const_iterator, Args&&...);
  iterator insert(value_type const&);
  iterator insert(value_type&&);
  iterator insert(const_iterator, value_type const&);
  iterator insert(const_iterator, value_type&&);
  template<typename InputIterator> void insert(InputIterator, InputIterator);
  iterator erase(const_iterator);
  size_type erase(key_type const&);
  iterator erase(const_iterator, const_iterator);
  void quick_erase(const_iterator);
  void erase_return_void(const_iterator);
  void clear();
  void swap(unordered_multimap&);

  // observers
  hasher hash_function() const;
  key_equal key_eq() const;

  // lookup
  iterator find(key_type const&);
  const_iterator find(key_type const&) const;
  template<typename CompatibleKey, typename CompatibleHash,
           typename CompatiblePredicate>
    iterator find(CompatibleKey const&, CompatibleHash const&,
                  CompatiblePredicate const&);
  template<typename CompatibleKey, typename CompatibleHash,
           typename CompatiblePredicate>
    const_iterator
    find(CompatibleKey const&, CompatibleHash const&,
         CompatiblePredicate const&) const;
  size_type count(key_type const&) const;
  std::pair<iterator, iterator> equal_range(key_type const&);
  std::pair<const_iterator, const_iterator> equal_range(key_type const&) const;

  // bucket interface
  size_type bucket_count() const;
  size_type max_bucket_count() const;
  size_type bucket_size(size_type) const;
  size_type bucket(key_type const&) const;
  local_iterator begin(size_type);
  const_local_iterator begin(size_type) const;
  local_iterator end(size_type);
  const_local_iterator end(size_type) const;
  const_local_iterator cbegin(size_type) const;
  const_local_iterator cend(size_type);

  // hash policy
  float load_factor() const;
  float max_load_factor() const;
  void max_load_factor(float);
  void rehash(size_type);
  void reserve(size_type);
};

// Equality Comparisons
template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  bool operator==(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&,
                  unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&);
template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  bool operator!=(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&,
                  unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const&);

// swap
template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  void swap(unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&,
            unordered_multimap<Key, Mapped, Hash, Pred, Alloc>&);

Description

Template Parameters

<colgroup>
<col>
<col>
</colgroup>

Key

Key must be Erasable from the container
                        (i.e. allocator_traits can destroy it).

Mapped

Mapped must be Erasable from the container
                        (i.e. allocator_traits can destroy it).

Hash
A unary function object type that acts a hash function for a Key. It takes a single argument of type Key and returns a value of type std::size_t.

Pred
A binary function object that implements an equivalence relation on values of type Key.
                        A binary function object that induces an equivalence relation on values of type Key.
                        It takes two arguments of type Key and returns a value of type bool.

Alloc
An allocator whose value type is the same as the container's value type.

The elements are organized into buckets. Keys with the same hash code are stored in the same bucket and elements with equivalent keys are stored next to each other.

The number of buckets can be automatically increased by a call to insert, or as the result of calling rehash.

unordered_multimap
        public
       types

typedef typename allocator_type::pointer pointer;

                value_type* if
                allocator_type::pointer is not defined.

typedef typename allocator_type::const_pointer const_pointer;

                boost::pointer_to_other<pointer, value_type>::type
                if allocator_type::const_pointer is not defined.

typedef implementation-defined size_type;

An unsigned integral type.

size_type can represent any non-negative value of difference_type.

typedef implementation-defined difference_type;

A signed integral type.

Is identical to the difference type of iterator and const_iterator.

typedef implementation-defined iterator;

An iterator whose value type is value_type.

The iterator category is at least a forward iterator.

Convertible to const_iterator.

typedef implementation-defined const_iterator;

A constant iterator whose value type is value_type.

The iterator category is at least a forward iterator.

typedef implementation-defined local_iterator;

An iterator with the same value type, difference type and pointer and reference type as iterator.

A local_iterator object can be used to iterate through a single bucket.

typedef implementation-defined const_local_iterator;

A constant iterator with the same value type, difference type and pointer and reference type as const_iterator.

A const_local_iterator object can be used to iterate through a single bucket.

unordered_multimap
        public
       construct/copy/destruct

explicit unordered_multimap(size_type n = implementation-defined,
                            hasher const& hf = hasher(),
                            key_equal const& eq = key_equal(),
                            allocator_type const& a = allocator_type());

Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Postconditions:

size() == 0

Requires:

If the defaults are used, hasher, key_equal and
                allocator_type need to be DefaultConstructible.

template<typename InputIterator>
  unordered_multimap(InputIterator f, InputIterator l,
                     size_type n = implementation-defined,
                     hasher const& hf = hasher(),
                     key_equal const& eq = key_equal(),
                     allocator_type const& a = allocator_type());

Constructs an empty container with at least n buckets, using hf as the hash function, eq as the key equality predicate, a as the allocator and a maximum load factor of 1.0 and inserts the elements from [f, l) into it.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

If the defaults are used, hasher, key_equal and
                allocator_type need to be DefaultConstructible.

unordered_multimap(unordered_multimap const&);

The copy constructor. Copies the contained elements, hash function, predicate, maximum load factor and allocator.

If Allocator::select_on_container_copy_construction
              exists and has the right signature, the allocator will be
              constructed from its result.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is copy constructible

unordered_multimap(unordered_multimap &&);

The move constructor.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Notes:

This is implemented using Boost.Move.

Requires:

                value_type is move constructible.

                On compilers without rvalue reference support the
                emulation does not support moving without calling
                boost::move if value_type is
                not copyable. So, for example, you can't return the
                container from a function.

explicit unordered_multimap(Allocator const& a);

Constructs an empty container, using allocator a.

unordered_multimap(unordered_multimap const& x, Allocator const& a);

Constructs an container, copying x's contained elements, hash function, predicate, maximum load factor, but using allocator a.

~unordered_multimap();

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Notes:

The destructor is applied to every element, and all memory is deallocated

unordered_multimap& operator=(unordered_multimap const&);

The assignment operator. Copies the contained elements, hash function, predicate and maximum load factor but not the allocator.

If Alloc::propagate_on_container_copy_assignment
              exists and Alloc::propagate_on_container_copy_assignment::value
               is true, the allocator is overwritten, if not the
              copied elements are created using the existing
              allocator.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is copy constructible

unordered_multimap& operator=(unordered_multimap &&);

The move assignment operator.

If Alloc::propagate_on_container_move_assignment
              exists and Alloc::propagate_on_container_move_assignment::value
               is true, the allocator is overwritten, if not the
              moved elements are created using the existing
              allocator.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Notes:

                On compilers without rvalue references, this is emulated using
                Boost.Move. Note that on some compilers the copy assignment
                operator may be used in some circumstances.

Requires:

                value_type is move constructible.

allocator_type get_allocator() const;

unordered_multimap size and capacity

bool empty() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

size() == 0

size_type size() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

std::distance(begin(), end())

size_type max_size() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

size() of the largest possible container.

unordered_multimap iterators

iterator begin();
const_iterator begin() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.

iterator end();
const_iterator end() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

An iterator which refers to the past-the-end value for the container.

const_iterator cbegin() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

A constant iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container.

const_iterator cend() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

A constant iterator which refers to the past-the-end value for the container.

unordered_multimap modifiers

template<typename... Args> iterator emplace(Args&&... args);

Inserts an object, constructed with the arguments args, in the container.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is EmplaceConstructible into
                  X from args.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

If the compiler doesn't support variadic template arguments or rvalue
                      references, this is emulated for up to 10 arguments, with no support
                      for rvalue references or move semantics.

Since existing std::pair implementations don't support
                      std::piecewise_construct this emulates it,
                      but using boost::unordered::piecewise_construct.

template<typename... Args>
  iterator emplace_hint(const_iterator hint, Args&&... args);

Inserts an object, constructed with the arguments args, in the container.

hint is a suggestion to where the element should be inserted.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is EmplaceConstructible into
                  X from args.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key.

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

If the compiler doesn't support variadic template arguments or rvalue
                      references, this is emulated for up to 10 arguments, with no support
                      for rvalue references or move semantics.

Since existing std::pair implementations don't support
                      std::piecewise_construct this emulates it,
                      but using boost::unordered::piecewise_construct.

iterator insert(value_type const& obj);

Inserts obj in the container.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is CopyInsertable.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

iterator insert(value_type&& obj);

Inserts obj in the container.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is MoveInsertable.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

iterator insert(const_iterator hint, value_type const& obj);

Inserts obj in the container.

hint is a suggestion to where the element should be inserted.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is CopyInsertable.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key.

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

iterator insert(const_iterator hint, value_type&& obj);

Inserts obj in the container.

hint is a suggestion to where the element should be inserted.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is MoveInsertable.

Returns:

An iterator pointing to the inserted element.

Throws:

If an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

The standard is fairly vague on the meaning of the hint. But the only practical way to use it, and the only way that Boost.Unordered supports is to point to an existing element with the same key.

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

template<typename InputIterator>
  void insert(InputIterator first, InputIterator last);

Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

value_type is EmplaceConstructible into
                  X from *first.

Throws:

When inserting a single element, if an exception is thrown by an operation other than a call to hasher the function has no effect.

Notes:

Can invalidate iterators, but only if the insert causes the load factor to be greater to or equal to the maximum load factor.

Pointers and references to elements are never invalidated.

iterator erase(const_iterator position);

Erase the element pointed to by position.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The iterator following position before the erasure.

Throws:

Only throws an exception if it is thrown by hasher or key_equal.

Notes:

                  In older versions this could be inefficient because it had to search
                  through several buckets to find the position of the returned iterator.
                  The data structure has been changed so that this is no longer the case,
                  and the alternative erase methods have been deprecated.

size_type erase(key_type const& k);

Erase all elements with key equivalent to k.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The number of elements erased.

Throws:

Only throws an exception if it is thrown by hasher or key_equal.

iterator erase(const_iterator first, const_iterator last);

Erases the elements in the range from first to last.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The iterator following the erased elements - i.e. last.

Throws:

Only throws an exception if it is thrown by hasher or key_equal.

In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.

void quick_erase(const_iterator position);

Erase the element pointed to by position.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Throws:

Only throws an exception if it is thrown by hasher or key_equal.

In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.

Notes:

                  This method was implemented because returning an iterator to
                  the next element from erase was expensive, but
                  the container has been redesigned so that is no longer the
                  case. So this method is now deprecated.

void erase_return_void(const_iterator position);

Erase the element pointed to by position.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Throws:

Only throws an exception if it is thrown by hasher or key_equal.

In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.

Notes:

                  This method was implemented because returning an iterator to
                  the next element from erase was expensive, but
                  the container has been redesigned so that is no longer the
                  case. So this method is now deprecated.

void clear();

Erases all elements in the container.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Postconditions:

size() == 0

Throws:

Never throws an exception.

void swap(unordered_multimap&);

Swaps the contents of the container with the parameter.

If Allocator::propagate_on_container_swap is declared and
                  Allocator::propagate_on_container_swap::value is true then the
                  containers' allocators are swapped. Otherwise, swapping with unequal allocators
                  results in undefined behavior.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Throws:

Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.

Notes:

The exception specifications aren't quite the same as the C++11 standard, as
                  the equality predieate and hash function are swapped using their copy constructors.

unordered_multimap observers

hasher hash_function() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The container's hash function.

key_equal key_eq() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The container's key equality predicate.

unordered_multimap lookup

iterator find(key_type const& k);
const_iterator find(key_type const& k) const;
template<typename CompatibleKey, typename CompatibleHash,
         typename CompatiblePredicate>
  iterator find(CompatibleKey const& k, CompatibleHash const& hash,
                CompatiblePredicate const& eq);
template<typename CompatibleKey, typename CompatibleHash,
         typename CompatiblePredicate>
  const_iterator
  find(CompatibleKey const& k, CompatibleHash const& hash,
       CompatiblePredicate const& eq) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

An iterator pointing to an element with key equivalent to k, or b.end() if no such element exists.

Notes:

                The templated overloads are a non-standard extensions which
                allows you to use a compatible hash function and equality
                predicate for a key of a different type in order to avoid
                an expensive type cast. In general, its use is not encouraged.

size_type count(key_type const& k) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The number of elements with key equivalent to k.

std::pair<iterator, iterator> equal_range(key_type const& k);
std::pair<const_iterator, const_iterator> equal_range(key_type const& k) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

A range containing all elements with key equivalent to k.
                  If the container doesn't container any such elements, returns
                  std::make_pair(b.end(),b.end()).

unordered_multimap bucket interface

size_type bucket_count() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The number of buckets.

size_type max_bucket_count() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

An upper bound on the number of buckets.

size_type bucket_size(size_type n) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

n < bucket_count()

Returns:

The number of elements in bucket n.

size_type bucket(key_type const& k) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The index of the bucket which would contain an element with key k.

Postconditions:

The return value is less than bucket_count()

local_iterator begin(size_type n);
const_local_iterator begin(size_type n) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

n shall be in the range [0, bucket_count()).

Returns:

A local iterator pointing the first element in the bucket with index n.

local_iterator end(size_type n);
const_local_iterator end(size_type n) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

n shall be in the range [0, bucket_count()).

Returns:

A local iterator pointing the 'one past the end' element in the bucket with index n.

const_local_iterator cbegin(size_type n) const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

n shall be in the range [0, bucket_count()).

Returns:

A constant local iterator pointing the first element in the bucket with index n.

const_local_iterator cend(size_type n);

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Requires:

n shall be in the range [0, bucket_count()).

Returns:

A constant local iterator pointing the 'one past the end' element in the bucket with index n.

unordered_multimap hash policy

float load_factor() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

The average number of elements per bucket.

float max_load_factor() const;

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Returns:

Returns the current maximum load factor.

void max_load_factor(float z);

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Effects:

Changes the container's maximum load factor, using z as a hint.

void rehash(size_type n);

Changes the number of buckets so that there at least n buckets, and so that the load factor is less than the maximum load factor.

Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Throws:

The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.

void reserve(size_type n);

Invalidates iterators, and changes the order of elements. Pointers and references to elements are not invalidated.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Throws:

The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.

unordered_multimap Equality Comparisons

template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  bool operator==(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& x,
                  unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& y);

Return true if x.size() ==
                y.size and for every equivalent key group in
                x, there is a group in y
                for the same key, which is a permutation (using
                operator== to compare the value types).

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Notes:

The behavior of this function was changed to match
                  the C++11 standard in Boost 1.48.

Behavior is undefined if the two containers don't have
                    equivalent equality predicates.

template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  bool operator!=(unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& x,
                  unordered_multimap<Key, Mapped, Hash, Pred, Alloc> const& y);

Return false if x.size() ==
                y.size and for every equivalent key group in
                x, there is a group in y
                for the same key, which is a permutation (using
                operator== to compare the value types).

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Notes:

The behavior of this function was changed to match
                  the C++11 standard in Boost 1.48.

Behavior is undefined if the two containers don't have
                    equivalent equality predicates.

unordered_multimap swap

template<typename Key, typename Mapped, typename Hash, typename Pred,
         typename Alloc>
  void swap(unordered_multimap<Key, Mapped, Hash, Pred, Alloc>& x,
            unordered_multimap<Key, Mapped, Hash, Pred, Alloc>& y);

Swaps the contents of x and y.

If Allocator::propagate_on_container_swap is declared and
                  Allocator::propagate_on_container_swap::value is true then the
                  containers' allocators are swapped. Otherwise, swapping with unequal allocators
                  results in undefined behavior.

<colgroup>
<col align="left" valign="top">
<col>
</colgroup>

Effects:

x.swap(y)

Throws:

Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of key_equal or hasher.

Notes:

The exception specifications aren't quite the same as the C++11 standard, as
                  the equality predieate and hash function are swapped using their copy constructors.

Copyright © 2003, 2004 Jeremy B. Maitin-Shepard
Copyright © 2005-2008 Daniel
      James

        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


text:
  {{'label.anchor.manageoffices' | translate}}

{{'label.addnewofficeormodifyordeactivateofficeormodifyofficeheirarchy' | translate}}

  {{'label.anchor.manageholidays' | translate}}

{{'label.defineholidaysforoffices' | translate}}

  {{'label.anchor.manageemployees' | translate}}

{{'label.aemployeerepresentsloanofficerswithnoaccesstosystem' | translate}}

  {{'label.anchor.currencyconfig' | translate}}

{{'label.currenciesavailableacrossorganizationfordifferentproducts' | translate}}

  {{'label.anchor.managefunds' | translate}}

{{'label.fundsareassociatedwithloans' | translate}}

  {{ 'label.anchor.bulkloanreassignment' | translate}}

{{'label.easywaytoreassignalltheloanfromonelotoanotherlo' | translate}}


text:
class Entity : public SceneNode{

public:

    enum FacingDirection{
        Left,
        Right
    };

    typedef std::unique_ptr<Entity> Ptr;

public:

    explicit Entity(b2Body *entityBody);
    sf::Vector2f getRenderPosition() const;
    void setRenderPosition(sf::Vector2f position);
    b2Vec2 getPosition() const;
    void setVelocity(b2Vec2 velocity);
    b2Vec2 getVelocity() const;
    sf::FloatRect getBoundingBox() const;

protected:
    b2Vec2 mVelocity;
    b2Vec2 mPreviousPosition;
    AnimatedSprite mSprite;
    b2Body *mB2Body;
};


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

    <TextView
        android:id="@+id/id_textview_more_title"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="#6bfafa"
        android:gravity="center_vertical"
        android:paddingLeft="8dp" />

    <com.guohao.custom.LoadMore
        android:id="@+id/id_loadmore"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ListView
            android:id="@+id/id_listview_more_movie"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbarSize="3dp"
            android:scrollbarThumbVertical="@color/scrollBar" >
        </ListView>
    </com.guohao.custom.LoadMore>

</LinearLayout>