// NewPremailerFromString take in a document in string format
// and create a goquery.Document
// and then create and Premailer instance.
973629
func NewPremailerFromString(doc string, options *Options) (Premailer, error) {
	read := strings.NewReader(doc)
	d, err := goquery.NewDocumentFromReader(read)
	if err != nil {
		return nil, err
	}
	return NewPremailer(d, options), nil
}
1206197
func NewFromString(encoded string) (*Value, error) {
	out, err := base64.RawURLEncoding.DecodeString(encoded)
	if err != nil {
		return nil, err
	}

	return New(out), nil
}
88960
func NewBadParameterErrorFromString(param string, actual interface{}, errorMessage string) BadParameterError {
	return BadParameterError{parameter: param, value: actual, errorMessage: errorMessage}
}
1113761
func NewFromString(cur, size string) Page {
	return New(number.DefaultInt(cur, 1), number.DefaultInt(size, DefaultPageSize))
}
1265411
func NewString(val string, p *string) *String {
	*p = val
	return (*String)(p)
}
709850
func (fw *Framework) NewReplyFromMessage(version string, msg *Message) (rep protocol.Reply, err error) {
	if msg.Type() != "reply" {
		err = fmt.Errorf("Cannot use `%s` message to construct a Reply", msg.Type())
		return
	}

	if msg.Request == nil {
		err = fmt.Errorf("Cannot create a Reply from Messages without Requests")
		return
	}

	req, err := fw.NewRequestFromMessage(version, msg.Request)
	if err != nil {
		return
	}

	rep, err = fw.NewReply(req)
	rep.SetMessage(msg.Payload)

	return
}
817426
func (u *Unit) ValueFromString(str string) (*Value, error) {
	s := &Value{unit: u}

	if err := s.Set(str); err != nil {
		return nil, err
	}
	return s, nil
}
488364
func SelectFromStringsFromReader(messageToPrint string, options []string, inputReader io.Reader) (string, error) {
	fmt.Printf("%s\n", messageToPrint)
	fmt.Println("Please select from the list:")
	for idx, anOption := range options {
		fmt.Printf("[%d] : %s\n", idx+1, anOption)
	}

	selectedOptionNum, err := AskForIntFromReader("(type in the option's number, then hit Enter)", inputReader)
	if err != nil {
		return "", err
	}

	if selectedOptionNum < 1 {
		return "", fmt.Errorf("invalid option: You entered a number less than 1")
	}
	if selectedOptionNum > int64(len(options)) {
		return "", fmt.Errorf("invalid option: You entered a number greater than the last option's number")
	}
	return options[selectedOptionNum-1], nil
}
1282749
func New(callback func(string)) *StringForwarder {
	if callback == nil {
		// Nothing to forward to, so no need to start the loop().
		// We'll just count the discardCount.
		return &StringForwarder{stopped: true}
	}
	forwarder := &StringForwarder{}
	forwarder.cond = sync.NewCond(&forwarder.mu)
	go forwarder.loop(callback)
	return forwarder
}
807918
func SelectFromStringsFromReaderWithDefault(messageToPrint string, defaultValue int, options []string, inputReader io.Reader) (string, error) {
	fmt.Printf("%s\n", messageToPrint)
	fmt.Println("Please select from the list:")
	for idx, anOption := range options {
		fmt.Printf("[%d] : %s\n", idx+1, anOption)
	}

	selectedOptionNum, err := AskForIntFromReaderWithDefault("(type in the option's number, then hit Enter)", defaultValue, inputReader)
	if err != nil {
		return "", err
	}

	if selectedOptionNum < 1 {
		return "", fmt.Errorf("invalid option: You entered a number less than 1")
	}
	if selectedOptionNum > int64(len(options)) {
		return "", fmt.Errorf("invalid option: You entered a number greater than the last option's number")
	}
	return options[selectedOptionNum-1], nil
}
1255799
func StringFromBytes(v []byte) string {
	// In Go 1.3, this string conversion in the map lookup does not allocate
	// to make a new string. We depend on Go 1.3, so this is always free:
	if s, ok := internStr[string(v)]; ok {
		return s
	}
	return string(v)
}
1099409
func NewQueryStringQuery(query string) *QueryStringQuery {
	q := &QueryStringQuery{newFtsQueryBase()}
	q.options["query"] = query
	return q
}
431324
func NewStringSimple(s string) StringAttribute {
	result := &StringSimple{
		NewAttribute(NORMAL, nil, nil),
	}
	result.Set(s)
	return result
}
618377
func CreateFrom(stringDate string) (*Carbon, error) {
	var carbon = Now()
	var err error
	var tm time.Time
	for _, format := range TimeFormats {
		tm, err = time.Parse(format, stringDate)
		if err == nil {
			carbon.Time = tm
			break
		}
	}

	return carbon, err
}
191893
func FiltersFromString(newRegex string) (map[string]*regexp.Regexp, error) {
	if newRegex == "" {
		return nil, nil
	}
	lines := strings.Split(newRegex, "\n")
	newFilters := make(map[string]*regexp.Regexp, len(lines))
	for _, line := range lines {
		lineParts := strings.SplitN(line, ":", 2)
		if len(lineParts) != 2 || lineParts[0] == "" || lineParts[1] == "" {
			return nil, errors.Errorf("Cannot parse line %s", line)
		}
		reg, err := regexp.Compile(lineParts[1])
		if err != nil {
			return nil, errors.Annotatef(err, "Cannot parse regex line %s", line)
		}
		newFilters[lineParts[0]] = reg
	}
	return newFilters, nil
}
278064
func NewMessageFromRequest(req protocol.Request, replyto string, choria *Framework) (msg *Message, err error) {
	reqm, err := NewMessage(req.Message(), req.Agent(), req.Collective(), "request", nil, choria)
	if err != nil {
		return msg, fmt.Errorf("could not create request message: %s", err)
	}

	if replyto != "" {
		reqm.replyTo = replyto
	}

	msg, err = NewMessage(req.Message(), req.Agent(), req.Collective(), "reply", reqm, choria)
	if err != nil {
		return msg, err
	}

	msg.RequestID = req.RequestID()
	msg.TTL = req.TTL()
	msg.TimeStamp = req.Time()
	msg.Filter, _ = req.Filter()
	msg.SenderID = choria.Config.Identity
	msg.SetBase64Payload(req.Message())
	msg.req = req

	return
}
1174062
func NewValueString(v string) Value {
	return Value{
		typ:     TBinary,
		tbinary: unsafeStringToBytes(v),
	}
}