This is an Australian 915Mhz edition of 1.0.8v libDot. Library for LoRa communication using MultiTech MDOT.

Dependents:   LoraGPSLogger

Committer:
Mike Fiore
Date:
Wed Jun 24 17:03:08 2015 -0500
Revision:
1:9f30fbe9e9c1
Child:
7:683dba5d576f
add README, LICENSE, headers, and library - from git tag mbed_24June2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:9f30fbe9e9c1 1 /************************************************
Mike Fiore 1:9f30fbe9e9c1 2 * MultiTech MTDOT Library
Mike Fiore 1:9f30fbe9e9c1 3 * Copyright (c) 2015 MultiTech Systems
Mike Fiore 1:9f30fbe9e9c1 4 *
Mike Fiore 1:9f30fbe9e9c1 5 * See LICENSE file for license information
Mike Fiore 1:9f30fbe9e9c1 6 ***********************************************/
Mike Fiore 1:9f30fbe9e9c1 7
Mike Fiore 1:9f30fbe9e9c1 8 #ifndef MTSTEXT_H
Mike Fiore 1:9f30fbe9e9c1 9 #define MTSTEXT_H
Mike Fiore 1:9f30fbe9e9c1 10
Mike Fiore 1:9f30fbe9e9c1 11 #include <string>
Mike Fiore 1:9f30fbe9e9c1 12 #include <vector>
Mike Fiore 1:9f30fbe9e9c1 13 #include <stddef.h>
Mike Fiore 1:9f30fbe9e9c1 14 #include <stdint.h>
Mike Fiore 1:9f30fbe9e9c1 15 #include <stdio.h>
Mike Fiore 1:9f30fbe9e9c1 16 #include <string.h>
Mike Fiore 1:9f30fbe9e9c1 17
Mike Fiore 1:9f30fbe9e9c1 18 namespace mts
Mike Fiore 1:9f30fbe9e9c1 19 {
Mike Fiore 1:9f30fbe9e9c1 20
Mike Fiore 1:9f30fbe9e9c1 21 /** This class contains a number of static methods for manipulating strings and other
Mike Fiore 1:9f30fbe9e9c1 22 * text data.
Mike Fiore 1:9f30fbe9e9c1 23 */
Mike Fiore 1:9f30fbe9e9c1 24 class Text
Mike Fiore 1:9f30fbe9e9c1 25 {
Mike Fiore 1:9f30fbe9e9c1 26 public:
Mike Fiore 1:9f30fbe9e9c1 27 /** This static method can be used to pull out a string at the next line break. A
Mike Fiore 1:9f30fbe9e9c1 28 * break can either be a newline '\n', carriage return '\r' or both.
Mike Fiore 1:9f30fbe9e9c1 29 *
Mike Fiore 1:9f30fbe9e9c1 30 * @param source the source string to look for the line break on.
Mike Fiore 1:9f30fbe9e9c1 31 * @param start the start postion within the string to begin looking for the line
Mike Fiore 1:9f30fbe9e9c1 32 * break.
Mike Fiore 1:9f30fbe9e9c1 33 * @param cursor this value will be updated with the index for the next available character
Mike Fiore 1:9f30fbe9e9c1 34 * after the line break. If a line break is not found returns -1.
Mike Fiore 1:9f30fbe9e9c1 35 * @returns the string beginning with the start index up to including the line breaks.
Mike Fiore 1:9f30fbe9e9c1 36 */
Mike Fiore 1:9f30fbe9e9c1 37 static std::string getLine(const std::string& source, const size_t& start, size_t& cursor);
Mike Fiore 1:9f30fbe9e9c1 38
Mike Fiore 1:9f30fbe9e9c1 39 /** This is a static method for splitting strings using a delimeter value.
Mike Fiore 1:9f30fbe9e9c1 40 *
Mike Fiore 1:9f30fbe9e9c1 41 * @param str the string to try and split.
Mike Fiore 1:9f30fbe9e9c1 42 * @param delimiter the delimeter value to split on as a character.
Mike Fiore 1:9f30fbe9e9c1 43 * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
Mike Fiore 1:9f30fbe9e9c1 44 * The default is 0.
Mike Fiore 1:9f30fbe9e9c1 45 * @returns an ordered vector of strings conatining the splits of the original string.
Mike Fiore 1:9f30fbe9e9c1 46 */
Mike Fiore 1:9f30fbe9e9c1 47 static std::vector<std::string> split(const std::string& str, char delimiter, int limit = 0);
Mike Fiore 1:9f30fbe9e9c1 48
Mike Fiore 1:9f30fbe9e9c1 49 /** This is a static method for splitting strings using a delimeter value.
Mike Fiore 1:9f30fbe9e9c1 50 *
Mike Fiore 1:9f30fbe9e9c1 51 * @param str the string to try and split.
Mike Fiore 1:9f30fbe9e9c1 52 * @param delimiter the delimeter value to split on as a string.
Mike Fiore 1:9f30fbe9e9c1 53 * @param limit the maximum number of splits. If equal to 0 it splits as amny times as possible.
Mike Fiore 1:9f30fbe9e9c1 54 * The default is 0.
Mike Fiore 1:9f30fbe9e9c1 55 * @returns an ordered vector of strings conatining the splits of the original string.
Mike Fiore 1:9f30fbe9e9c1 56 */
Mike Fiore 1:9f30fbe9e9c1 57 static std::vector<std::string> split(const std::string& str, const std::string& delimiter, int limit = 0);
Mike Fiore 1:9f30fbe9e9c1 58
Mike Fiore 1:9f30fbe9e9c1 59 static std::string readString(char* index, int length);
Mike Fiore 1:9f30fbe9e9c1 60
Mike Fiore 1:9f30fbe9e9c1 61 static std::string toUpper(const std::string str);
Mike Fiore 1:9f30fbe9e9c1 62
Mike Fiore 1:9f30fbe9e9c1 63 std::string float2String(double val, int precision);
Mike Fiore 1:9f30fbe9e9c1 64
Mike Fiore 1:9f30fbe9e9c1 65 static std::string bin2hexString(const std::vector<uint8_t>& data, const char* delim = "", bool leadingZeros = false);
Mike Fiore 1:9f30fbe9e9c1 66
Mike Fiore 1:9f30fbe9e9c1 67 static std::string bin2hexString(const uint8_t* data, const uint32_t len, const char* delim = "", bool leadingZeros = false);
Mike Fiore 1:9f30fbe9e9c1 68
Mike Fiore 1:9f30fbe9e9c1 69 static void ltrim(std::string& str, const char* args);
Mike Fiore 1:9f30fbe9e9c1 70
Mike Fiore 1:9f30fbe9e9c1 71 static void rtrim(std::string& str, const char* args);
Mike Fiore 1:9f30fbe9e9c1 72
Mike Fiore 1:9f30fbe9e9c1 73 static void trim(std::string& str, const char* args);
Mike Fiore 1:9f30fbe9e9c1 74
Mike Fiore 1:9f30fbe9e9c1 75 private:
Mike Fiore 1:9f30fbe9e9c1 76 // Safety for class with only static methods
Mike Fiore 1:9f30fbe9e9c1 77 Text();
Mike Fiore 1:9f30fbe9e9c1 78 Text(const Text& other);
Mike Fiore 1:9f30fbe9e9c1 79 Text& operator=(const Text& other);
Mike Fiore 1:9f30fbe9e9c1 80 };
Mike Fiore 1:9f30fbe9e9c1 81
Mike Fiore 1:9f30fbe9e9c1 82 }
Mike Fiore 1:9f30fbe9e9c1 83
Mike Fiore 1:9f30fbe9e9c1 84 #endif